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.

streams: Mark messages as read only for unsubscribed streams.

Sahil Batra0bfe973b6580
diff --git a/zerver/actions/streams.py b/zerver/actions/streams.py
index e98dca0ae94..a8ddb721491 100644
--- a/zerver/actions/streams.py
+++ b/zerver/actions/streams.py
@@ -607,7 +607,9 @@ def bulk_remove_subscriptions(
event = {
"type": "mark_stream_messages_as_read",
"user_profile_id": user_profile.id,
- "stream_recipient_ids": [stream.recipient_id for stream in streams],
+ "stream_recipient_ids": [
+ stream.recipient_id for stream in streams_by_user[user_profile.id]
+ ],
}
queue_json_publish("deferred_work", event)
diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py
index d3fb42204f0..f556ecd59be 100644
--- a/zerver/tests/test_subs.py
+++ b/zerver/tests/test_subs.py
@@ -4668,10 +4668,10 @@ class SubscriptionAPITest(ZulipTestCase):
self.subscribe(user3, "private_stream")
# Apart from 3 peer-remove events and 2 unsubscribe event, because `bulk_remove_subscriptions`
- # also marks are read messages in those streams as read, so emits 8 `message_flags` events too
+ # also marks are read messages in those streams as read, so emits 6 `message_flags` events too
# (for each of the notification bot messages).
events: List[Mapping[str, Any]] = []
- with self.tornado_redirected_to_list(events, expected_num_events=13):
+ with self.tornado_redirected_to_list(events, expected_num_events=11):
with queries_captured() as query_count:
with cache_tries_captured() as cache_count:
bulk_remove_subscriptions(
@@ -4681,7 +4681,7 @@ class SubscriptionAPITest(ZulipTestCase):
acting_user=None,
)
- self.assert_length(query_count, 27)
+ self.assert_length(query_count, 23)
self.assert_length(cache_count, 3)
peer_events = [e for e in events if e["event"].get("op") == "peer_remove"]