mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 16:37:23 +00:00
events: Update subscriber list on peer_remove for unsubscribed stream.
We update the subscriber list on peer_remove event for unsubscribed streams also.
This commit is contained in:
@@ -727,7 +727,7 @@ def apply_event(state: Dict[str, Any],
|
|||||||
elif event['op'] == 'peer_remove':
|
elif event['op'] == 'peer_remove':
|
||||||
stream_ids = set(event["stream_ids"])
|
stream_ids = set(event["stream_ids"])
|
||||||
user_ids = set(event["user_ids"])
|
user_ids = set(event["user_ids"])
|
||||||
for sub_dict in [state["subscriptions"]]:
|
for sub_dict in [state["subscriptions"], state['unsubscribed']]:
|
||||||
for sub in sub_dict:
|
for sub in sub_dict:
|
||||||
if sub["stream_id"] in stream_ids:
|
if sub["stream_id"] in stream_ids:
|
||||||
subscribers = set(sub["subscribers"]) - user_ids
|
subscribers = set(sub["subscribers"]) - user_ids
|
||||||
|
|||||||
@@ -1844,7 +1844,8 @@ class SubscribeActionTest(BaseAction):
|
|||||||
|
|
||||||
stream = get_stream("test_stream", self.user_profile.realm)
|
stream = get_stream("test_stream", self.user_profile.realm)
|
||||||
|
|
||||||
# Now remove the first user, to test the normal unsubscribe flow
|
# Now remove the first user, to test the normal unsubscribe flow and
|
||||||
|
# 'peer_remove' event for subscribed streams.
|
||||||
action = lambda: bulk_remove_subscriptions(
|
action = lambda: bulk_remove_subscriptions(
|
||||||
[self.example_user('othello')],
|
[self.example_user('othello')],
|
||||||
[stream],
|
[stream],
|
||||||
@@ -1872,6 +1873,19 @@ class SubscribeActionTest(BaseAction):
|
|||||||
'test_stream',
|
'test_stream',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.subscribe(self.example_user("iago"), "test_stream")
|
||||||
|
|
||||||
|
# Remove the user to test 'peer_remove' event flow for unsubscribed stream.
|
||||||
|
action = lambda: bulk_remove_subscriptions(
|
||||||
|
[self.example_user('iago')],
|
||||||
|
[stream],
|
||||||
|
get_client("website"))
|
||||||
|
events = self.verify_action(
|
||||||
|
action,
|
||||||
|
include_subscribers=include_subscribers,
|
||||||
|
state_change_expected=include_subscribers)
|
||||||
|
check_subscription_peer_remove('events[0]', events[0])
|
||||||
|
|
||||||
# Now resubscribe a user, to make sure that works on a vacated stream
|
# Now resubscribe a user, to make sure that works on a vacated stream
|
||||||
action = lambda: self.subscribe(self.example_user("hamlet"), "test_stream")
|
action = lambda: self.subscribe(self.example_user("hamlet"), "test_stream")
|
||||||
events = self.verify_action(
|
events = self.verify_action(
|
||||||
|
|||||||
Reference in New Issue
Block a user