events: Update subscriber list on peer_add for unsubscribed streams.

We update the subscriber list on peer_add event for unsubscribed
streams as well.
This commit is contained in:
sahil839
2020-09-01 11:16:12 +05:30
committed by Tim Abbott
parent 733d26aef2
commit 571bb62e3d
2 changed files with 9 additions and 2 deletions

View File

@@ -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

View File

@@ -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(