Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
notifications: Fix the if/elif order in the manage_preferences block.
Prakhar Pratyush5f6dd83696ea
diff --git a/templates/zerver/emails/missed_message.html b/templates/zerver/emails/missed_message.htmlindex d87a3668bb7..6a303a8e0b8 100644--- a/templates/zerver/emails/missed_message.html+++ b/templates/zerver/emails/missed_message.html@@ -29,14 +29,14 @@{% trans %}You are receiving this because you were personally mentioned.{% endtrans %}<br />{% elif mentioned_user_group_name %}{% trans %}You are receiving this because @{{ mentioned_user_group_name }} was mentioned.{% endtrans %}<br />- {% elif wildcard_mentioned %}- {% trans %}You are receiving this because everyone was mentioned in #{{ stream_name }}.{% endtrans %}<br />{% elif followed_topic_wildcard_mentioned %}{% trans %}You are receiving this because you have wildcard mention notifications enabled for topics you follow.{% endtrans %}<br />- {% elif stream_email_notify %}- {% trans %}You are receiving this because you have email notifications enabled for #{{ stream_name }}.{% endtrans %}<br />+ {% elif wildcard_mentioned %}+ {% trans %}You are receiving this because everyone was mentioned in #{{ stream_name }}.{% endtrans %}<br />{% elif followed_topic_email_notify %}{% trans %}You are receiving this because you have email notifications enabled for topics you follow.{% endtrans %}<br />+ {% elif stream_email_notify %}+ {% trans %}You are receiving this because you have email notifications enabled for #{{ stream_name }}.{% endtrans %}<br />{% endif %}{% if reply_to_zulip %}{% trans notif_url=realm_uri + "/#settings/notifications" %}Reply to this email directly, <a href="{{ narrow_url }}">view it in {{ realm_name }} Zulip</a>, or <a href="{{ notif_url }}">manage email preferences</a>.{% endtrans %}diff --git a/templates/zerver/emails/missed_message.txt b/templates/zerver/emails/missed_message.txtindex 8536a967236..ccbfbb7800a 100644--- a/templates/zerver/emails/missed_message.txt+++ b/templates/zerver/emails/missed_message.txt@@ -25,14 +25,14 @@ See {{ alert_notif_url }} for more details.{% trans %}You are receiving this because you were personally mentioned.{% endtrans %}{% elif mentioned_user_group_name %}{% trans %}You are receiving this because @{{ mentioned_user_group_name }} was mentioned.{% endtrans %}-{% elif wildcard_mentioned %}-{% trans %}You are receiving this because everyone was mentioned in #{{ stream_name }}.{% endtrans %}{% elif followed_topic_wildcard_mentioned %}{% trans %}You are receiving this because you have wildcard mention notifications enabled for topics you follow.{% endtrans %}-{% elif stream_email_notify %}-{% trans %}You are receiving this because you have email notifications enabled for #{{ stream_name }}.{% endtrans %}+{% elif wildcard_mentioned %}+{% trans %}You are receiving this because everyone was mentioned in #{{ stream_name }}.{% endtrans %}{% elif followed_topic_email_notify %}{% trans %}You are receiving this because you have email notifications enabled for topics you follow.{% endtrans %}+{% elif stream_email_notify %}+{% trans %}You are receiving this because you have email notifications enabled for #{{ stream_name }}.{% endtrans %}{% endif %}{% if reply_to_zulip %}diff --git a/zerver/tests/test_email_notifications.py b/zerver/tests/test_email_notifications.pyindex d59f16847a6..0bf40b80b9b 100644--- a/zerver/tests/test_email_notifications.py+++ b/zerver/tests/test_email_notifications.py@@ -1061,7 +1061,7 @@ class TestMissedMessages(ZulipTestCase):for text in expected_email_include:self.assertIn(text, self.normalize_string(mail.outbox[0].body))- def test_user_group_over_wildcard_mention_priority(self) -> None:+ def test_user_group_over_followed_topic_wildcard_mention_priority(self) -> None:hamlet = self.example_user("hamlet")cordelia = self.example_user("cordelia")othello = self.example_user("othello")@@ -1070,7 +1070,9 @@ class TestMissedMessages(ZulipTestCase):get_realm("zulip"), "hamlet_and_cordelia", [hamlet, cordelia], acting_user=None)- wildcard_mentioned_message_id = self.send_stream_message(othello, "Denmark", "@**all**")+ followed_topic_wildcard_mentioned_message_id = self.send_stream_message(+ othello, "Denmark", "@**all**"+ )user_group_mentioned_message_id = self.send_stream_message(othello, "Denmark", "@*hamlet_and_cordelia*")@@ -1079,8 +1081,8 @@ class TestMissedMessages(ZulipTestCase):hamlet.id,[{- "message_id": wildcard_mentioned_message_id,- "trigger": "wildcard_mentioned",+ "message_id": followed_topic_wildcard_mentioned_message_id,+ "trigger": "followed_topic_wildcard_mentioned","mentioned_user_group_id": None,},{@@ -1099,19 +1101,52 @@ class TestMissedMessages(ZulipTestCase):for text in expected_email_include:self.assertIn(text, self.normalize_string(mail.outbox[0].body))- def test_wildcard_over_stream_mention_priority(self) -> None:+ def test_followed_topic_wildcard_over_wildcard_mention_priority(self) -> None:hamlet = self.example_user("hamlet")othello = self.example_user("othello")- stream_mentioned_message_id = self.send_stream_message(othello, "Denmark", "1")wildcard_mentioned_message_id = self.send_stream_message(othello, "Denmark", "@**all**")+ followed_topic_wildcard_mentioned_message_id = self.send_stream_message(+ othello, "Denmark", "@**all**"+ )handle_missedmessage_emails(hamlet.id,[{- "message_id": stream_mentioned_message_id,- "trigger": "stream_email_notify",+ "message_id": wildcard_mentioned_message_id,+ "trigger": "wildcard_mentioned",+ "mentioned_user_group_id": None,+ },+ {+ "message_id": followed_topic_wildcard_mentioned_message_id,+ "trigger": "followed_topic_wildcard_mentioned",+ "mentioned_user_group_id": None,+ },+ ],+ )++ expected_email_include = [+ "Othello, the Moor of Venice: > @**all** > @**all** -- ",+ "You are receiving this because you have wildcard mention notifications enabled for topics you follow.",+ ]++ for text in expected_email_include:+ self.assertIn(text, self.normalize_string(mail.outbox[0].body))++ def test_wildcard_mention_over_followed_topic_notify_priority(self) -> None:+ hamlet = self.example_user("hamlet")+ othello = self.example_user("othello")++ followed_topic_mentioned_message_id = self.send_stream_message(othello, "Denmark", "1")+ wildcard_mentioned_message_id = self.send_stream_message(othello, "Denmark", "@**all**")++ handle_missedmessage_emails(+ hamlet.id,+ [+ {+ "message_id": followed_topic_mentioned_message_id,+ "trigger": "followed_topic_email_notify","mentioned_user_group_id": None,},{@@ -1130,6 +1165,37 @@ class TestMissedMessages(ZulipTestCase):for text in expected_email_include:self.assertIn(text, self.normalize_string(mail.outbox[0].body))+ def test_followed_topic_notify_over_stream_message_notify_priority(self) -> None:+ hamlet = self.example_user("hamlet")+ othello = self.example_user("othello")++ stream_mentioned_message_id = self.send_stream_message(othello, "Denmark", "0")+ followed_topic_mentioned_message_id = self.send_stream_message(othello, "Denmark", "1")++ handle_missedmessage_emails(+ hamlet.id,+ [+ {+ "message_id": stream_mentioned_message_id,+ "trigger": "stream_email_notify",+ "mentioned_user_group_id": None,+ },+ {+ "message_id": followed_topic_mentioned_message_id,+ "trigger": "followed_topic_email_notify",+ "mentioned_user_group_id": None,+ },+ ],+ )++ expected_email_include = [+ "Othello, the Moor of Venice: > 0 > 1 -- ",+ "You are receiving this because you have email notifications enabled for topics you follow.",+ ]++ for text in expected_email_include:+ self.assertIn(text, self.normalize_string(mail.outbox[0].body))+def test_include_realm_name_in_missedmessage_emails_subject(self) -> None:user = self.example_user("hamlet")