mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 11:22:04 +00:00
streams: Fix empty description in stream change notifications.
Send 'No description' text when either the old or new stream description is empty, to avoid odd looking notifications.
This commit is contained in:
@@ -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* **"
|
||||
|
||||
@@ -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"},
|
||||
|
||||
Reference in New Issue
Block a user