From 3af56bf2dc719c59d93ecd54a7040521c297509a Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Wed, 27 Jul 2022 18:42:52 +0200 Subject: [PATCH] Tweak Announce processing --- app/boxes.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/boxes.py b/app/boxes.py index f1b5b7e..0bdd1a1 100644 --- a/app/boxes.py +++ b/app/boxes.py @@ -1390,15 +1390,23 @@ async def save_to_inbox( ) db_session.add(notif) else: + # Only show the announce in the stream if it comes from an actor + # in the following collection + followings = await _get_following(db_session) + is_from_following = inbox_object.actor.ap_id in { + f.ap_actor_id for f in followings + } + # This is announce for a maybe unknown object if relates_to_inbox_object: # We already know about this object, show the announce in the - # stream if it's not already there + # stream if it's not already there, from an followed actor + # and if we haven't seen it recently if ( now() - as_utc(relates_to_inbox_object.ap_published_at) # type: ignore ) > timedelta(hours=1): - inbox_object.is_hidden_from_stream = False + inbox_object.is_hidden_from_stream = not is_from_following else: # Save it as an inbox object if not activity_ro.activity_object_ap_id: @@ -1423,14 +1431,8 @@ async def save_to_inbox( db_session.add(announced_inbox_object) await db_session.flush() inbox_object.relates_to_inbox_object_id = announced_inbox_object.id - - # Only show the announce in the stream if it comes from an actor - # in the following collection - followings = await _get_following(db_session) - is_from_following = inbox_object.actor.ap_id in { - f.ap_actor_id for f in followings - } inbox_object.is_hidden_from_stream = not is_from_following + elif activity_ro.ap_type in ["Like", "Announce"]: if not relates_to_outbox_object: logger.info(