mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 05:53:43 +00:00
minor: Move include_subscribers guards in apply_event.
This sets us up for a cleaner diff in an upcoming commit.
This commit is contained in:
@@ -702,9 +702,6 @@ def apply_event(
|
|||||||
state['realm_password_auth_enabled'] = (value['Email'] or value['LDAP'])
|
state['realm_password_auth_enabled'] = (value['Email'] or value['LDAP'])
|
||||||
state['realm_email_auth_enabled'] = value['Email']
|
state['realm_email_auth_enabled'] = value['Email']
|
||||||
elif event['type'] == "subscription":
|
elif event['type'] == "subscription":
|
||||||
if not include_subscribers and event['op'] in ['peer_add', 'peer_remove']:
|
|
||||||
return
|
|
||||||
|
|
||||||
if event['op'] in ["add"]:
|
if event['op'] in ["add"]:
|
||||||
if not include_subscribers:
|
if not include_subscribers:
|
||||||
# Avoid letting 'subscribers' entries end up in the list
|
# Avoid letting 'subscribers' entries end up in the list
|
||||||
@@ -752,21 +749,25 @@ def apply_event(
|
|||||||
if sub['name'].lower() == event['name'].lower():
|
if sub['name'].lower() == event['name'].lower():
|
||||||
sub[event['property']] = event['value']
|
sub[event['property']] = event['value']
|
||||||
elif event['op'] == 'peer_add':
|
elif event['op'] == 'peer_add':
|
||||||
stream_ids = set(event["stream_ids"])
|
if include_subscribers:
|
||||||
user_ids = set(event["user_ids"])
|
stream_ids = set(event["stream_ids"])
|
||||||
for sub_dict in [state["subscriptions"], state['unsubscribed'], state["never_subscribed"]]:
|
user_ids = set(event["user_ids"])
|
||||||
for sub in sub_dict:
|
|
||||||
if sub["stream_id"] in stream_ids:
|
for sub_dict in [state["subscriptions"], state["unsubscribed"], state["never_subscribed"]]:
|
||||||
subscribers = set(sub["subscribers"]) | user_ids
|
for sub in sub_dict:
|
||||||
sub["subscribers"] = sorted(list(subscribers))
|
if sub["stream_id"] in stream_ids:
|
||||||
|
subscribers = set(sub["subscribers"]) | user_ids
|
||||||
|
sub["subscribers"] = sorted(list(subscribers))
|
||||||
elif event['op'] == 'peer_remove':
|
elif event['op'] == 'peer_remove':
|
||||||
stream_ids = set(event["stream_ids"])
|
if include_subscribers:
|
||||||
user_ids = set(event["user_ids"])
|
stream_ids = set(event["stream_ids"])
|
||||||
for sub_dict in [state["subscriptions"], state['unsubscribed'], state['never_subscribed']]:
|
user_ids = set(event["user_ids"])
|
||||||
for sub in sub_dict:
|
|
||||||
if sub["stream_id"] in stream_ids:
|
for sub_dict in [state["subscriptions"], state["unsubscribed"], state["never_subscribed"]]:
|
||||||
subscribers = set(sub["subscribers"]) - user_ids
|
for sub in sub_dict:
|
||||||
sub["subscribers"] = sorted(list(subscribers))
|
if sub["stream_id"] in stream_ids:
|
||||||
|
subscribers = set(sub["subscribers"]) - user_ids
|
||||||
|
sub["subscribers"] = sorted(list(subscribers))
|
||||||
elif event['type'] == "presence":
|
elif event['type'] == "presence":
|
||||||
if slim_presence:
|
if slim_presence:
|
||||||
user_key = str(event['user_id'])
|
user_key = str(event['user_id'])
|
||||||
|
|||||||
Reference in New Issue
Block a user