Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
channels: Auto-mark channel archival event messages as read. Previously, channel archival event messages were unread in archived channels, which makes the archived channel accessible from the inbox view. This commit fixes this issue by auto-marking the channel archival event message as read.
Aditya Kumar Kasaudhan21412b9f792e
diff --git a/zerver/actions/streams.py b/zerver/actions/streams.pyindex 1b9460d0549..b1f79d82bab 100644--- a/zerver/actions/streams.py+++ b/zerver/actions/streams.py@@ -143,6 +143,7 @@ def do_deactivate_stream(stream: Stream, *, acting_user: UserProfile | None) ->topic_name=str(Realm.STREAM_EVENTS_NOTIFICATION_TOPIC_NAME),content=_("Channel {channel_name} has been archived.").format(channel_name=stream.name),archived_channel_notice=True,+ limit_unread_user_ids=set(),)diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.pyindex 73aab7f4210..d70775c95c8 100644--- a/zerver/tests/test_subs.py+++ b/zerver/tests/test_subs.py@@ -1628,6 +1628,9 @@ class StreamAdminTest(ZulipTestCase):self.subscribe(user_profile, stream.name)do_change_user_role(user_profile, UserProfile.ROLE_REALM_ADMINISTRATOR, acting_user=None)+ # Subscribe Cordelia to verify that the archive notification is marked as read for all subscribers.+ cordelia = self.example_user("cordelia")+ self.subscribe(cordelia, stream.name)result = self.client_delete(f"/json/streams/{stream.id}")self.assert_json_success(result)subscription_exists = (@@ -1638,6 +1641,14 @@ class StreamAdminTest(ZulipTestCase):.exists())self.assertTrue(subscription_exists)+ # Assert that a notification message was sent for the archive.+ message = self.get_last_message()+ expected_content = f"Channel {stream.name} has been archived."+ self.assertEqual(message.content, expected_content)++ # Assert that the message is read.+ for um in UserMessage.objects.filter(message=message):+ self.assertTrue(um.flags & UserMessage.flags.read)def test_deactivate_stream_via_user_group_permissions(self) -> None:user_profile = self.example_user("hamlet")@@ -1647,6 +1658,10 @@ class StreamAdminTest(ZulipTestCase):user_profile_group = check_add_user_group(user_profile.realm, "user_profile_group", [user_profile], acting_user=user_profile)++ # Subscribe Cordelia to verify that the archive notification is marked as read for all subscribers.+ cordelia = self.example_user("cordelia")+ self.subscribe(cordelia, stream.name)do_change_stream_group_based_setting(stream,"can_administer_channel_group",@@ -1663,6 +1678,14 @@ class StreamAdminTest(ZulipTestCase):.exists())self.assertTrue(subscription_exists)+ # Assert that a notification message was sent for the archive.+ message = self.get_last_message()+ expected_content = f"Channel {stream.name} has been archived."+ self.assertEqual(message.content, expected_content)++ # Assert that the message is read.+ for um in UserMessage.objects.filter(message=message):+ self.assertTrue(um.flags & UserMessage.flags.read)def test_deactivate_stream_removes_default_stream(self) -> None:stream = self.make_stream("new_stream")