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_email_auth_enabled'] = value['Email']
 | 
			
		||||
    elif event['type'] == "subscription":
 | 
			
		||||
        if not include_subscribers and event['op'] in ['peer_add', 'peer_remove']:
 | 
			
		||||
            return
 | 
			
		||||
 | 
			
		||||
        if event['op'] in ["add"]:
 | 
			
		||||
            if not include_subscribers:
 | 
			
		||||
                # Avoid letting 'subscribers' entries end up in the list
 | 
			
		||||
@@ -752,17 +749,21 @@ def apply_event(
 | 
			
		||||
                if sub['name'].lower() == event['name'].lower():
 | 
			
		||||
                    sub[event['property']] = event['value']
 | 
			
		||||
        elif event['op'] == 'peer_add':
 | 
			
		||||
            if include_subscribers:
 | 
			
		||||
                stream_ids = set(event["stream_ids"])
 | 
			
		||||
                user_ids = set(event["user_ids"])
 | 
			
		||||
            for sub_dict in [state["subscriptions"], state['unsubscribed'], state["never_subscribed"]]:
 | 
			
		||||
 | 
			
		||||
                for sub_dict in [state["subscriptions"], state["unsubscribed"], state["never_subscribed"]]:
 | 
			
		||||
                    for sub in sub_dict:
 | 
			
		||||
                        if sub["stream_id"] in stream_ids:
 | 
			
		||||
                            subscribers = set(sub["subscribers"]) | user_ids
 | 
			
		||||
                            sub["subscribers"] = sorted(list(subscribers))
 | 
			
		||||
        elif event['op'] == 'peer_remove':
 | 
			
		||||
            if include_subscribers:
 | 
			
		||||
                stream_ids = set(event["stream_ids"])
 | 
			
		||||
                user_ids = set(event["user_ids"])
 | 
			
		||||
            for sub_dict in [state["subscriptions"], state['unsubscribed'], state['never_subscribed']]:
 | 
			
		||||
 | 
			
		||||
                for sub_dict in [state["subscriptions"], state["unsubscribed"], state["never_subscribed"]]:
 | 
			
		||||
                    for sub in sub_dict:
 | 
			
		||||
                        if sub["stream_id"] in stream_ids:
 | 
			
		||||
                            subscribers = set(sub["subscribers"]) - user_ids
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user