mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
refactor: Split out public/private logic for peer events.
This doesn't change anything yet, but the goal is to eventually optimize events for the case where one user (typically a new user) gets subscribed to multiple public streams.
This commit is contained in:
@@ -2945,12 +2945,13 @@ def send_peer_subscriber_events(
|
||||
|
||||
assert op in ["peer_add", "peer_remove"]
|
||||
|
||||
for stream_id, altered_user_ids in altered_user_dict.items():
|
||||
stream = stream_dict[stream_id]
|
||||
|
||||
if stream.is_in_zephyr_realm and not stream.invite_only:
|
||||
continue
|
||||
private_stream_ids = [
|
||||
stream_id for stream_id in altered_user_dict
|
||||
if stream_dict[stream_id].invite_only
|
||||
]
|
||||
|
||||
for stream_id in private_stream_ids:
|
||||
altered_user_ids = altered_user_dict[stream_id]
|
||||
peer_user_ids = peer_id_dict[stream_id] - altered_user_ids
|
||||
|
||||
if peer_user_ids:
|
||||
@@ -2958,7 +2959,27 @@ def send_peer_subscriber_events(
|
||||
event = dict(
|
||||
type="subscription",
|
||||
op=op,
|
||||
stream_id=stream.id,
|
||||
stream_id=stream_id,
|
||||
user_id=new_user_id,
|
||||
)
|
||||
send_event(realm, event, peer_user_ids)
|
||||
|
||||
public_stream_ids = [
|
||||
stream_id for stream_id in altered_user_dict
|
||||
if not stream_dict[stream_id].invite_only
|
||||
and not stream_dict[stream_id].is_in_zephyr_realm
|
||||
]
|
||||
|
||||
for stream_id in public_stream_ids:
|
||||
altered_user_ids = altered_user_dict[stream_id]
|
||||
peer_user_ids = peer_id_dict[stream_id] - altered_user_ids
|
||||
|
||||
if peer_user_ids:
|
||||
for new_user_id in altered_user_ids:
|
||||
event = dict(
|
||||
type="subscription",
|
||||
op=op,
|
||||
stream_id=stream_id,
|
||||
user_id=new_user_id,
|
||||
)
|
||||
send_event(realm, event, peer_user_ids)
|
||||
|
||||
Reference in New Issue
Block a user