Only do the followed query if needed

This commit is contained in:
Andrew Godwin 2023-01-08 14:24:27 -07:00
parent f16dcd04e4
commit 4bea1006b1

View file

@ -38,12 +38,12 @@ class FanOutStates(StateGraph):
# or it's a reply to us or the author # or it's a reply to us or the author
add = True add = True
mentioned = {identity.id for identity in post.mentions.all()} mentioned = {identity.id for identity in post.mentions.all()}
if post.in_reply_to:
followed = await sync_to_async(set)( followed = await sync_to_async(set)(
fan_out.identity.outbound_follows.filter( fan_out.identity.outbound_follows.filter(
state__in=FollowStates.group_active() state__in=FollowStates.group_active()
).values_list("target_id", flat=True) ).values_list("target_id", flat=True)
) )
if post.in_reply_to:
interested_in = followed.union( interested_in = followed.union(
{post.author_id, fan_out.identity_id} {post.author_id, fan_out.identity_id}
) )