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 handling in new stream notifications.

Tim Abbottc78909718488
diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py
index 07f7ce695c6..915ca5a41ec 100644
--- a/zerver/tests/test_subs.py
+++ b/zerver/tests/test_subs.py
@@ -3924,6 +3924,7 @@ class SubscriptionAPITest(ZulipTestCase):
principals=orjson.dumps([self.user_profile.id]).decode(),
),
)
+ target_stream = get_stream(invite_streams[0], self.test_realm)
msg = self.get_second_to_last_message()
self.assertEqual(msg.recipient.type, Recipient.STREAM)
@@ -3934,6 +3935,16 @@ class SubscriptionAPITest(ZulipTestCase):
)
self.assertEqual(msg.content, expected_msg)
+ msg = self.get_last_message()
+ self.assertEqual(msg.recipient.type, Recipient.STREAM)
+ self.assertEqual(msg.recipient.type_id, target_stream.id)
+ self.assertEqual(msg.sender_id, self.notification_bot(self.test_realm).id)
+ expected_msg = (
+ f"**Public** stream created by @_**{invitee_full_name}|{invitee.id}**. **Description:**\n"
+ "```` quote\n*No description.*\n````"
+ )
+ self.assertEqual(msg.content, expected_msg)
+
def test_successful_cross_realm_notification(self) -> None:
"""
Calling POST /json/users/me/subscriptions in a new realm
diff --git a/zerver/views/streams.py b/zerver/views/streams.py
index b3310659f3d..a03a3cf4560 100644
--- a/zerver/views/streams.py
+++ b/zerver/views/streams.py
@@ -681,6 +681,10 @@ def send_messages_for_new_subscribers(
sender = get_system_bot(settings.NOTIFICATION_BOT, user_profile.realm_id)
for stream in created_streams:
with override_language(stream.realm.default_language):
+ if stream.description == "":
+ stream_description = "*" + _("No description.") + "*"
+ else:
+ stream_description = stream.description
notifications.append(
internal_prep_stream_message(
sender=sender,
@@ -696,7 +700,7 @@ def send_messages_for_new_subscribers(
is_web_public=stream.is_web_public,
),
)
- + f"\n```` quote\n{stream.description}\n````",
+ + f"\n```` quote\n{stream_description}\n````",
),
)