actions: Fixed deactivated user IDs being included for stream events.

This was a mostly harmless bug, since those users cannot have active
clients, but fixing it will improve performance in any Zulip
organization where the vast majority of users are deactivated.
This commit is contained in:
Tim Abbott
2021-04-19 13:23:02 -07:00
committed by Tim Abbott
parent 6509c4f8f4
commit e4932bd952

View File

@@ -310,16 +310,15 @@ def can_access_stream_user_ids(stream: Stream) -> Set[int]:
def private_stream_user_ids(stream_id: int) -> Set[int]:
# TODO: Find similar queries elsewhere and de-duplicate this code.
subscriptions = get_active_subscriptions_for_stream_id(
stream_id, include_deactivated_users=True
stream_id, include_deactivated_users=False
)
return {sub["user_profile_id"] for sub in subscriptions.values("user_profile_id")}
def public_stream_user_ids(stream: Stream) -> Set[int]:
guest_subscriptions = get_active_subscriptions_for_stream_id(
stream.id, include_deactivated_users=True
stream.id, include_deactivated_users=False
).filter(user_profile__role=UserProfile.ROLE_GUEST)
guest_subscriptions = {
sub["user_profile_id"] for sub in guest_subscriptions.values("user_profile_id")