summaryrefslogtreecommitdiffstats
path: root/activities/models
diff options
context:
space:
mode:
authorAndrew Godwin2022-11-25 18:20:59 -0700
committerAndrew Godwin2022-11-25 18:20:59 -0700
commit5fe5f0495518e43aa4ab9f6831c4bc27a0be9458 (patch)
treeb3c29c33f950743b576140f3dbca3a2e438c256b /activities/models
parenta4c9e85da28d0e76eae2410bf41c328af82373f0 (diff)
downloadtakahe-5fe5f0495518e43aa4ab9f6831c4bc27a0be9458.tar.gz
takahe-5fe5f0495518e43aa4ab9f6831c4bc27a0be9458.tar.bz2
takahe-5fe5f0495518e43aa4ab9f6831c4bc27a0be9458.zip
Exclude replies in most situations from timelines
Diffstat (limited to 'activities/models')
-rw-r--r--activities/models/fan_out.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/activities/models/fan_out.py b/activities/models/fan_out.py
index 5eb20f3..3e5c4da 100644
--- a/activities/models/fan_out.py
+++ b/activities/models/fan_out.py
@@ -23,13 +23,23 @@ class FanOutStates(StateGraph):
post = await fan_out.subject_post.afetch_full()
if fan_out.identity.local:
# Make a timeline event directly
- # TODO: Exclude replies to people we don't follow
- await sync_to_async(TimelineEvent.add_post)(
- identity=fan_out.identity,
- post=post,
- )
+ # If it's a reply, we only add it if we follow at least one
+ # of the people mentioned.
+ add = True
+ mentioned = {identity.id for identity in post.mentions.all()}
+ if post.in_reply_to:
+ add = False
+ async for follow in fan_out.identity.outbound_follows.all():
+ if follow.target_id in mentioned:
+ add = True
+ break
+ if add:
+ await sync_to_async(TimelineEvent.add_post)(
+ identity=fan_out.identity,
+ post=post,
+ )
# We might have been mentioned
- if fan_out.identity in list(post.mentions.all()):
+ if fan_out.identity.id in mentioned:
TimelineEvent.add_mentioned(
identity=fan_out.identity,
post=post,