From 31a2dd695092f39cb68bafbc05fee1855989fbd6 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Wed, 27 Jul 2022 12:31:32 +0200 Subject: [PATCH] Hide announce from non-followers in the stream --- app/boxes.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/boxes.py b/app/boxes.py index d3339d2..f1b5b7e 100644 --- a/app/boxes.py +++ b/app/boxes.py @@ -1423,7 +1423,14 @@ 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 - inbox_object.is_hidden_from_stream = False + + # 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(