events: Update subscriber list on peer_remove for never subscribed stream.

We now update the subscriber list on peer_remove event for never
subscribed streams also.
This commit is contained in:
sahil839 2020-08-31 22:03:09 +05:30 committed by Tim Abbott
parent af9b153ee3
commit 733d26aef2
2 changed files with 12 additions and 1 deletions

View File

@ -727,7 +727,7 @@ def apply_event(state: Dict[str, Any],
elif event['op'] == 'peer_remove':
stream_ids = set(event["stream_ids"])
user_ids = set(event["user_ids"])
for sub_dict in [state["subscriptions"], state['unsubscribed']]:
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

@ -1483,6 +1483,17 @@ class NormalActionsTest(BaseAction):
events = self.verify_action(action, num_events=2)
check_subscription_peer_add('events[1]', events[1])
def test_remove_other_user_never_subscribed(self) -> None:
self.subscribe(self.example_user("othello"), "test_stream")
stream = get_stream("test_stream", self.user_profile.realm)
action = lambda: bulk_remove_subscriptions(
[self.example_user('othello')],
[stream],
get_client("website"))
events = self.verify_action(action)
check_subscription_peer_remove('events[0]', events[0])
def test_do_delete_message_stream(self) -> None:
hamlet = self.example_user('hamlet')
msg_id = self.send_stream_message(hamlet, "Verona")