diff --git a/zerver/lib/events.py b/zerver/lib/events.py index 9a5ba58a0a..5c225e123f 100644 --- a/zerver/lib/events.py +++ b/zerver/lib/events.py @@ -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 diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index ea48b9fcbe..487a13a2d8 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -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")