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: Fix empty description in stream change notifications.

jai220120e631570502
diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py
index dcf3a52a047..f2bb8b8c764 100644
--- a/zerver/lib/actions.py
+++ b/zerver/lib/actions.py
@@ -5455,6 +5455,11 @@ def send_change_stream_description_notification(
user_mention = silent_mention_syntax_for_user(acting_user)
with override_language(stream.realm.default_language):
+ if new_description == "":
+ new_description = "*" + _("No description.") + "*"
+ if old_description == "":
+ old_description = "*" + _("No description.") + "*"
+
notification_string = (
_("{user} changed the description for this stream.").format(user=user_mention)
+ "\n\n* **"
diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py
index 915ca5a41ec..33739858c37 100644
--- a/zerver/tests/test_subs.py
+++ b/zerver/tests/test_subs.py
@@ -1633,6 +1633,50 @@ class StreamAdminTest(ZulipTestCase):
f"description is too long (limit: {Stream.MAX_DESCRIPTION_LENGTH} characters)",
)
+ result = self.client_patch(
+ f"/json/streams/{stream_id}",
+ {"description": ""},
+ )
+ self.assert_json_success(result)
+ stream = get_stream("stream_name1", realm)
+ self.assertEqual(stream.description, "")
+
+ messages = get_topic_messages(user_profile, stream, "stream events")
+ expected_notification = (
+ f"@_**{user_profile.full_name}|{user_profile.id}** changed the description for this stream.\n\n"
+ "* **Old description:**\n"
+ "```` quote\n"
+ "Test description\n"
+ "````\n"
+ "* **New description:**\n"
+ "```` quote\n"
+ "*No description.*\n"
+ "````"
+ )
+ self.assertEqual(messages[-1].content, expected_notification)
+
+ result = self.client_patch(
+ f"/json/streams/{stream_id}",
+ {"description": "Test description"},
+ )
+ self.assert_json_success(result)
+ stream = get_stream("stream_name1", realm)
+ self.assertEqual(stream.description, "Test description")
+
+ messages = get_topic_messages(user_profile, stream, "stream events")
+ expected_notification = (
+ f"@_**{user_profile.full_name}|{user_profile.id}** changed the description for this stream.\n\n"
+ "* **Old description:**\n"
+ "```` quote\n"
+ "*No description.*\n"
+ "````\n"
+ "* **New description:**\n"
+ "```` quote\n"
+ "Test description\n"
+ "````"
+ )
+ self.assertEqual(messages[-1].content, expected_notification)
+
result = self.client_patch(
f"/json/streams/{stream_id}",
{"description": "a\nmulti\nline\ndescription"},