mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-15 03:04:28 +00:00
Fixes invalid likes/boost
This commit is contained in:
parent
a8baa88fb5
commit
2464dd8782
3 changed files with 18 additions and 6 deletions
18
app.py
18
app.py
|
@ -930,7 +930,7 @@ def note_by_id(note_id):
|
|||
thread = _build_thread(data)
|
||||
app.logger.info(f"thread={thread!r}")
|
||||
|
||||
likes = list(
|
||||
raw_likes = list(
|
||||
DB.activities.find(
|
||||
{
|
||||
"meta.undo": False,
|
||||
|
@ -944,10 +944,15 @@ def note_by_id(note_id):
|
|||
}
|
||||
)
|
||||
)
|
||||
likes = [doc["meta"]["actor"] for doc in likes]
|
||||
likes = []
|
||||
for doc in raw_likes:
|
||||
try:
|
||||
likes.append(doc["meta"]["actor"])
|
||||
except Exception:
|
||||
app.logger.exception(f"invalid doc: {doc!r}")
|
||||
app.logger.info(f"likes={likes!r}")
|
||||
|
||||
shares = list(
|
||||
raw_shares = list(
|
||||
DB.activities.find(
|
||||
{
|
||||
"meta.undo": False,
|
||||
|
@ -960,7 +965,12 @@ def note_by_id(note_id):
|
|||
}
|
||||
)
|
||||
)
|
||||
shares = [doc["meta"]["actor"] for doc in shares]
|
||||
shares = []
|
||||
for doc in raw_shares:
|
||||
try:
|
||||
shares.append(doc["meta"]["actor"])
|
||||
except Exception:
|
||||
app.logger.exception(f"invalid doc: {doc!r}")
|
||||
app.logger.info(f"shares={shares!r}")
|
||||
|
||||
return render_template(
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
|
||||
{% if item | has_type('Announce') %}
|
||||
{% set boost_actor = item.meta.actor %}
|
||||
{% if boost_actor %}
|
||||
<p style="margin-left:70px;padding-bottom:5px;"><span class="bar-item-no-hover"><a style="color:#808080;" href="{{ boost_actor.url | get_url }}">{{ boost_actor.name or boost_actor.preferredUsername }}</a> boosted</span></p>
|
||||
{% endif %}
|
||||
{% if item.meta.object %}
|
||||
{{ utils.display_note(item.meta.object, ui=True) }}
|
||||
{% endif %}
|
||||
|
|
|
@ -195,14 +195,14 @@
|
|||
<div style="padding-top:20px;" class="pure-g">
|
||||
{% if likes %}
|
||||
<div class="pure-u-1-2">
|
||||
<h4 style="font-weight:normal"><strong>{{ meta.count_like }}</strong> likes</h4>{% for like in likes %}
|
||||
<h4 style="font-weight:normal"><strong>{{ likes|length }}</strong> likes</h4>{% for like in likes %}
|
||||
{{ display_actor_inline(like) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if shares %}
|
||||
<div class="pure-u-1-2">
|
||||
<h4 style="font-weight:normal"><strong>{{ meta.count_boost }}</strong> boosts</h4>{% for boost in shares %}
|
||||
<h4 style="font-weight:normal"><strong>{{ shares|length }}</strong> boosts</h4>{% for boost in shares %}
|
||||
{{ display_actor_inline(boost) }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue