Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
streams: Fix error while sending notice in deactivated stream.
Prakhar Pratyush7970e1fa4513
diff --git a/zerver/actions/streams.py b/zerver/actions/streams.pyindex 39ba1b4db34..1f06f3004ef 100644--- a/zerver/actions/streams.py+++ b/zerver/actions/streams.py@@ -1237,7 +1237,11 @@ def send_change_stream_permission_notification(new_policy=new_policy_name,)internal_send_stream_message(- sender, stream, str(Realm.STREAM_EVENTS_NOTIFICATION_TOPIC_NAME), notification_string+ sender,+ stream,+ str(Realm.STREAM_EVENTS_NOTIFICATION_TOPIC_NAME),+ notification_string,+ archived_channel_notice=stream.deactivated,)@@ -1467,7 +1471,11 @@ def send_stream_posting_permission_update_notification(new_setting_description=new_setting_description,)internal_send_stream_message(- sender, stream, str(Realm.STREAM_EVENTS_NOTIFICATION_TOPIC_NAME), notification_string+ sender,+ stream,+ str(Realm.STREAM_EVENTS_NOTIFICATION_TOPIC_NAME),+ notification_string,+ archived_channel_notice=stream.deactivated,)@@ -1526,6 +1534,7 @@ def do_rename_stream(stream: Stream, new_name: str, user_profile: UserProfile) -old_channel_name=f"**{old_name}**",new_channel_name=f"**{new_name}**",),+ archived_channel_notice=stream.deactivated,)@@ -1554,7 +1563,11 @@ def send_change_stream_description_notification()internal_send_stream_message(- sender, stream, str(Realm.STREAM_EVENTS_NOTIFICATION_TOPIC_NAME), notification_string+ sender,+ stream,+ str(Realm.STREAM_EVENTS_NOTIFICATION_TOPIC_NAME),+ notification_string,+ archived_channel_notice=stream.deactivated,)@@ -1644,7 +1657,11 @@ def send_change_stream_message_retention_days_notification(summary_line=summary_line,)internal_send_stream_message(- sender, stream, str(Realm.STREAM_EVENTS_NOTIFICATION_TOPIC_NAME), notification_string+ sender,+ stream,+ str(Realm.STREAM_EVENTS_NOTIFICATION_TOPIC_NAME),+ notification_string,+ archived_channel_notice=stream.deactivated,)diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.pyindex 962c6ade6ff..c03ed9b0ea2 100644--- a/zerver/tests/test_subs.py+++ b/zerver/tests/test_subs.py@@ -1154,6 +1154,42 @@ class StreamAdminTest(ZulipTestCase):old_style.save()self.assertEqual(set(deactivated_streams_by_old_name(realm, "old_style")), {old_style})+ def test_archived_channel_notice(self) -> None:+ desdemona = self.example_user("desdemona")+ channel = get_stream("Denmark", desdemona.realm)+ moderators_group = NamedUserGroup.objects.get(+ name=SystemGroups.MODERATORS, realm=channel.realm, is_system_group=True+ )+ self.login_user(desdemona)+ do_deactivate_stream(channel, acting_user=desdemona)+ self.assertTrue(channel.deactivated)++ param_to_notice_list = [+ ({"new_name": "New Denmark"}, f"@_**Desdemona|{desdemona.id}** renamed channel"),+ (+ {"description": "New description"},+ f"@_**Desdemona|{desdemona.id}** changed the description",+ ),+ (+ {"message_retention_days": orjson.dumps(2).decode()},+ f"@_**Desdemona|{desdemona.id}** has changed the [message retention period]",+ ),+ (+ {"can_send_message_group": orjson.dumps({"new": moderators_group.id}).decode()},+ f"@_**Desdemona|{desdemona.id}** changed the [posting permissions]",+ ),+ (+ {"is_private": orjson.dumps(False).decode()},+ f"@_**Desdemona|{desdemona.id}** changed the [access permissions]",+ ),+ ]++ for param, notice in param_to_notice_list:+ result = self.client_patch(f"/json/streams/{channel.id}", param)+ self.assert_json_success(result)+ message = self.get_last_message()+ self.assertIn(notice, message.content)+def test_unarchive_stream_active_stream(self) -> None:stream = self.make_stream("new_stream")with self.assertRaisesRegex(JsonableError, "Channel is not currently deactivated"):