Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
streams: Update formatting of retention change notification.
Shantanu4371705a4cee
diff --git a/zerver/lib/actions.py b/zerver/lib/actions.pyindex 9e4d12ee0d4..1c61042a6aa 100644--- a/zerver/lib/actions.py+++ b/zerver/lib/actions.py@@ -5429,25 +5429,29 @@ def send_change_stream_message_retention_days_notification(with override_language(stream.realm.default_language):if old_value == Stream.MESSAGE_RETENTION_SPECIAL_VALUES_MAP["unlimited"]:- notification_string = _(- "{user} has changed the [message retention period](/help/message-retention-policy) for this stream from "- "**Forever** to **{new_value} days**. Messages will be automatically deleted after {new_value} days."- )- notification_string = notification_string.format(user=user_mention, new_value=new_value)+ old_retention_period = _("Forever")+ new_retention_period = f"{new_value} days"+ summary_line = f"Messages in this stream will now be automatically deleted {new_value} days after they are sent."elif new_value == Stream.MESSAGE_RETENTION_SPECIAL_VALUES_MAP["unlimited"]:- notification_string = _(- "{user} has changed the [message retention period](/help/message-retention-policy) for this stream from "- "**{old_value} days** to **Forever**."- )- notification_string = notification_string.format(user=user_mention, old_value=old_value)+ old_retention_period = f"{old_value} days"+ new_retention_period = _("Forever")+ summary_line = _("Messages in this stream will now be retained forever.")else:- notification_string = _(- "{user} has changed the [message retention period](/help/message-retention-policy) for this stream from "- "**{old_value} days** to **{new_value} days**. Messages will be automatically deleted after {new_value} days."- )- notification_string = notification_string.format(- user=user_mention, old_value=old_value, new_value=new_value- )+ old_retention_period = f"{old_value} days"+ new_retention_period = f"{new_value} days"+ summary_line = f"Messages in this stream will now be automatically deleted {new_value} days after they are sent."+ notification_string = _(+ "{user} has changed the [message retention period](/help/message-retention-policy) for this stream:\n"+ "* **Old retention period**: {old_retention_period}\n"+ "* **New retention period**: {new_retention_period}\n\n"+ "{summary_line}"+ )+ notification_string = notification_string.format(+ user=user_mention,+ old_retention_period=old_retention_period,+ new_retention_period=new_retention_period,+ summary_line=summary_line,+ )internal_send_stream_message(sender, stream, Realm.STREAM_EVENTS_NOTIFICATION_TOPIC, notification_string)diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.pyindex 1cb48e9647c..ce6b625de7a 100644--- a/zerver/tests/test_subs.py+++ b/zerver/tests/test_subs.py@@ -1781,9 +1781,10 @@ class StreamAdminTest(ZulipTestCase):messages = get_topic_messages(user_profile, stream, "stream events")self.assert_length(messages, 1)expected_notification = (- f"@_**Desdemona|{user_profile.id}** has changed the [message retention period](/help/message-retention-policy) "- "for this stream from **Forever** to **2 days**. Messages will be automatically "- "deleted after 2 days."+ f"@_**Desdemona|{user_profile.id}** has changed the [message retention period](/help/message-retention-policy) for this stream:\n"+ "* **Old retention period**: Forever\n"+ "* **New retention period**: 2 days\n\n"+ "Messages in this stream will now be automatically deleted 2 days after they are sent.")self.assertEqual(messages[0].content, expected_notification)realm_audit_log = RealmAuditLog.objects.filter(@@ -1803,9 +1804,10 @@ class StreamAdminTest(ZulipTestCase):messages = get_topic_messages(user_profile, stream, "stream events")self.assert_length(messages, 2)expected_notification = (- f"@_**Desdemona|{user_profile.id}** has changed the [message retention period](/help/message-retention-policy) "- "for this stream from **2 days** to **8 days**. Messages will be automatically "- "deleted after 8 days."+ f"@_**Desdemona|{user_profile.id}** has changed the [message retention period](/help/message-retention-policy) for this stream:\n"+ "* **Old retention period**: 2 days\n"+ "* **New retention period**: 8 days\n\n"+ "Messages in this stream will now be automatically deleted 8 days after they are sent.")self.assertEqual(messages[1].content, expected_notification)realm_audit_log = RealmAuditLog.objects.filter(@@ -1826,8 +1828,10 @@ class StreamAdminTest(ZulipTestCase):messages = get_topic_messages(user_profile, stream, "stream events")self.assert_length(messages, 3)expected_notification = (- f"@_**Desdemona|{user_profile.id}** has changed the [message retention period](/help/message-retention-policy) "- "for this stream from **8 days** to **Forever**."+ f"@_**Desdemona|{user_profile.id}** has changed the [message retention period](/help/message-retention-policy) for this stream:\n"+ "* **Old retention period**: 8 days\n"+ "* **New retention period**: Forever\n\n"+ "Messages in this stream will now be retained forever.")self.assertEqual(messages[2].content, expected_notification)realm_audit_log = RealmAuditLog.objects.filter(