Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

events: Update subscriber list on peer_add for unsubscribed streams.

sahil839571bb62e3d1d
diff --git a/zerver/lib/events.py b/zerver/lib/events.py
index 5c225e123f4..ee5263de32b 100644
--- a/zerver/lib/events.py
+++ b/zerver/lib/events.py
@@ -719,7 +719,7 @@ def apply_event(state: Dict[str, Any],
elif event['op'] == 'peer_add':
stream_ids = set(event["stream_ids"])
user_ids = set(event["user_ids"])
- for sub_dict in [state["subscriptions"], 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
diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py
index 487a13a2d88..5427ee4d528 100644
--- a/zerver/tests/test_events.py
+++ b/zerver/tests/test_events.py
@@ -1884,7 +1884,14 @@ class SubscribeActionTest(BaseAction):
'test_stream',
)
- self.subscribe(self.example_user("iago"), "test_stream")
+ # Subscribe other user to test 'peer_add' event flow for unsubscribed stream.
+ action = lambda: self.subscribe(self.example_user("iago"), "test_stream")
+ events = self.verify_action(
+ action,
+ event_types=["subscription"],
+ include_subscribers=include_subscribers,
+ state_change_expected=include_subscribers)
+ check_subscription_peer_add('events[0]', events[0])
# Remove the user to test 'peer_remove' event flow for unsubscribed stream.
action = lambda: bulk_remove_subscriptions(