Show likes in the notifications
This commit is contained in:
parent
9431cb09d7
commit
cbd9d4e6da
4 changed files with 38 additions and 10 deletions
|
@ -280,16 +280,6 @@ class MicroblogPubBackend(Backend):
|
|||
{"$inc": {"meta.count_like": 1}, "$set": {"meta.liked": like.id}},
|
||||
)
|
||||
|
||||
DB.activities.update_one(
|
||||
{"remote_id": like.id},
|
||||
{
|
||||
"$set": {
|
||||
"meta.object": obj.to_dict(embed=True),
|
||||
"meta.object_actor": _actor_to_meta(obj.get_actor()),
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
@ensure_it_is_me
|
||||
def outbox_undo_like(self, as_actor: ap.Person, like: ap.Like) -> None:
|
||||
obj = like.get_object()
|
||||
|
|
2
app.py
2
app.py
|
@ -1397,6 +1397,7 @@ def admin_notifications():
|
|||
"type": ActivityType.UNDO.value,
|
||||
"activity.object.type": ActivityType.FOLLOW.value,
|
||||
}
|
||||
likes_query = {"type": ActivityType.LIKE.value}
|
||||
followed_query = {"type": ActivityType.ACCEPT.value}
|
||||
q = {
|
||||
"box": Box.INBOX.value,
|
||||
|
@ -1407,6 +1408,7 @@ def admin_notifications():
|
|||
new_followers_query,
|
||||
followed_query,
|
||||
unfollow_query,
|
||||
likes_query,
|
||||
],
|
||||
}
|
||||
inbox_data, older_than, newer_than = paginated_query(DB.activities, q)
|
||||
|
|
27
tasks.py
27
tasks.py
|
@ -176,6 +176,30 @@ def fetch_og_metadata(self, iri: str) -> None:
|
|||
self.retry(exc=err, countdown=int(random.uniform(2, 4) ** self.request.retries))
|
||||
|
||||
|
||||
@app.task(bind=True, max_retries=12)
|
||||
def cache_object(self, iri: str) -> None:
|
||||
try:
|
||||
activity = ap.fetch_remote_activity(iri)
|
||||
log.info(f"activity={activity!r}")
|
||||
|
||||
obj = activity.get_object()
|
||||
DB.activities.update_one(
|
||||
{"remote_id": activity.id},
|
||||
{
|
||||
"$set": {
|
||||
"meta.object": obj.to_dict(embed=True),
|
||||
"meta.object_actor": activitypub._actor_to_meta(obj.get_actor()),
|
||||
}
|
||||
},
|
||||
)
|
||||
except (ActivityGoneError, ActivityNotFoundError, NotAnActivityError):
|
||||
DB.activities.update_one({"remote_id": iri}, {"$set": {"meta.deleted": True}})
|
||||
log.exception(f"flagging activity {iri} as deleted, no object caching")
|
||||
except Exception as err:
|
||||
log.exception(f"failed to cache object for {iri}")
|
||||
self.retry(exc=err, countdown=int(random.uniform(2, 4) ** self.request.retries))
|
||||
|
||||
|
||||
@app.task(bind=True, max_retries=12)
|
||||
def cache_actor(self, iri: str, also_cache_attachments: bool = True) -> None:
|
||||
try:
|
||||
|
@ -185,6 +209,9 @@ def cache_actor(self, iri: str, also_cache_attachments: bool = True) -> None:
|
|||
if activity.has_type(ap.ActivityType.CREATE):
|
||||
fetch_og_metadata.delay(iri)
|
||||
|
||||
if activity.has_type([ap.ActivityType.LIKE, ap.ActivityType.ANNOUNCE]):
|
||||
cache_object.delay(iri)
|
||||
|
||||
actor = activity.get_actor()
|
||||
|
||||
cache_actor_with_inbox = False
|
||||
|
|
|
@ -20,6 +20,15 @@
|
|||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if item | has_type('Like') %}
|
||||
{% set boost_actor = item.meta.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> liked</span></p>
|
||||
{{ item }}
|
||||
{% if item.meta.object %}
|
||||
{{ utils.display_note(item.meta.object, ui=False, meta={'actor': item.meta.object_actor}) }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if item | has_type('Follow') %}
|
||||
<p style="margin-left:70px;padding-bottom:5px;"><span class="bar-item-no-hover">new follower</span> <!-- <a href="" class="bar-item">follow back</a></p> -->
|
||||
<div style="height: 100px;">
|
||||
|
|
Loading…
Reference in a new issue