make get_audience logic clearer

Retains 'direct' messages at the top of the logic tree to make it easier to understand.
In practice because direct messages are excluded from feeds anyway, this doesn't seem to make much difference, but it's easier to read.
This commit is contained in:
Hugh Rundle 2022-08-21 09:33:43 +10:00
parent 8d593e4498
commit cc97c52d12

View file

@ -111,8 +111,15 @@ class ActivityStream(RedisStore):
Q(id__in=status.user.blocks.all()) | Q(blocks=status.user) # not blocked
)
# only visible to the poster and mentioned users
if status.privacy == "direct":
audience = audience.filter(
Q(id=status.user.id) # if the user is the post's author
| Q(id__in=status.mention_users.all()) # if the user is mentioned
)
# don't show replies to statuses the user can't see
if status.reply_parent and status.reply_parent.privacy == "followers":
elif status.reply_parent and status.reply_parent.privacy == "followers":
audience = audience.filter(
Q(id=status.user.id) # if the user is the post's author
| Q(id=status.reply_parent.user.id) # if the user is the OG author
@ -121,12 +128,6 @@ class ActivityStream(RedisStore):
) # if the user is following both authors
).distinct()
# only visible to the poster and mentioned users
elif status.privacy == "direct":
audience = audience.filter(
Q(id=status.user.id) # if the user is the post's author
| Q(id__in=status.mention_users.all()) # if the user is mentioned
)
# only visible to the poster's followers and tagged users
elif status.privacy == "followers":
audience = audience.filter(