From d0ed35591bb5caea79f5b302b529d3bfc78f61b2 Mon Sep 17 00:00:00 2001 From: Henri Dickson <90480431+alphatownsman@users.noreply.github.com> Date: Tue, 6 Feb 2024 00:10:47 -0500 Subject: [PATCH 1/2] do not deliver follower-only post to hashtag followers --- activities/models/post.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/activities/models/post.py b/activities/models/post.py index fef4db4e..be0ce39f 100644 --- a/activities/models/post.py +++ b/activities/models/post.py @@ -766,19 +766,21 @@ def get_targets(self) -> Iterable[Identity]: for mention in self.mentions.all(): targets.add(mention) if self.visibility in [Post.Visibilities.public, Post.Visibilities.unlisted]: + # deliver edit to all previously interacted to this post for interaction in self.interactions.all(): targets.add(interaction.identity) - # Then, if it's not mentions only, also deliver to followers and all hashtag followers - if self.visibility != Post.Visibilities.mentioned: - for follower in self.author.inbound_follows.filter( - state__in=FollowStates.group_active() - ).select_related("source"): - targets.add(follower.source) + # deliver to all hashtag followers if self.hashtags: for follow in HashtagFollow.objects.by_hashtags( self.hashtags ).prefetch_related("identity"): targets.add(follow.identity) + # Then, if it's not mentions only, also deliver to followers + if self.visibility != Post.Visibilities.mentioned: + for follower in self.author.inbound_follows.filter( + state__in=FollowStates.group_active() + ).select_related("source"): + targets.add(follower.source) # If it's a reply, always include the original author if we know them reply_post = self.in_reply_to_post() From 0c991d1faf996ba10fcd1bb00acd52caa3f92463 Mon Sep 17 00:00:00 2001 From: Henri Dickson <90480431+alphatownsman@users.noreply.github.com> Date: Fri, 24 May 2024 09:15:20 -0400 Subject: [PATCH 2/2] deliver public post with hashtag to all hashtag followers --- activities/models/post.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/activities/models/post.py b/activities/models/post.py index be0ce39f..e25c6de4 100644 --- a/activities/models/post.py +++ b/activities/models/post.py @@ -769,12 +769,12 @@ def get_targets(self) -> Iterable[Identity]: # deliver edit to all previously interacted to this post for interaction in self.interactions.all(): targets.add(interaction.identity) - # deliver to all hashtag followers - if self.hashtags: - for follow in HashtagFollow.objects.by_hashtags( - self.hashtags - ).prefetch_related("identity"): - targets.add(follow.identity) + if self.visibility == Post.Visibilities.public and self.hashtags: + # deliver public post with hashtag to all hashtag followers + for follow in HashtagFollow.objects.by_hashtags( + self.hashtags + ).prefetch_related("identity"): + targets.add(follow.identity) # Then, if it's not mentions only, also deliver to followers if self.visibility != Post.Visibilities.mentioned: for follower in self.author.inbound_follows.filter(