diff --git a/templates/zerver/emails/missed_message.html b/templates/zerver/emails/missed_message.html
index d87a3668bb..6a303a8e0b 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 %}
{% 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 %}
{% trans notif_url=realm_uri + "/#settings/notifications" %}Reply to this email directly, view it in {{ realm_name }} Zulip, or manage email preferences.{% endtrans %}
diff --git a/templates/zerver/emails/missed_message.txt b/templates/zerver/emails/missed_message.txt
index 8536a96723..ccbfbb7800 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.py
index d59f16847a..0bf40b80b9 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": 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": stream_mentioned_message_id,
- "trigger": "stream_email_notify",
+ "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")