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.

mention: Soft-reactivate users receiving @topic mention notifications.

Prakhar Pratyush21a581876505
diff --git a/zerver/lib/soft_deactivation.py b/zerver/lib/soft_deactivation.py
index 4e2fa95cf3e..e57f2a4f81a 100644
--- a/zerver/lib/soft_deactivation.py
+++ b/zerver/lib/soft_deactivation.py
@@ -419,7 +419,11 @@ def soft_reactivate_if_personal_notification(
private_message = "private_message" in unique_triggers
personal_mention = "mentioned" in unique_triggers and mentioned_user_group_name is None
- if not private_message and not personal_mention:
+ topic_wildcard_mention = any(
+ trigger in unique_triggers
+ for trigger in ["topic_wildcard_mentioned", "topic_wildcard_mentioned_in_followed_topic"]
+ )
+ if not private_message and not personal_mention and not topic_wildcard_mention:
return
queue_soft_reactivation(user_profile.id)
diff --git a/zerver/tests/test_email_notifications.py b/zerver/tests/test_email_notifications.py
index 3bd3e4e367f..99bd0739aac 100644
--- a/zerver/tests/test_email_notifications.py
+++ b/zerver/tests/test_email_notifications.py
@@ -2130,6 +2130,21 @@ class TestMissedMessages(ZulipTestCase):
)
do_change_user_setting(hamlet, "wildcard_mentions_notify", False, acting_user=None)
+ # Topic wildcard mention in followed topic should soft reactivate the user
+ # hamlet should be a topic participant
+ self.send_stream_message(hamlet, "Denmark", "test message")
+ with self.soft_deactivate_and_check_long_term_idle(hamlet, expected=False):
+ mention = "@**topic**"
+ stream_mentioned_message_id = self.send_stream_message(othello, "Denmark", mention)
+ handle_missedmessage_emails(
+ hamlet.id,
+ {
+ stream_mentioned_message_id: MissedMessageData(
+ trigger="topic_wildcard_mentioned_in_followed_topic"
+ ),
+ },
+ )
+
# Stream wildcard mention in followed topic should NOT soft reactivate the user
with self.soft_deactivate_and_check_long_term_idle(hamlet, expected=True):
mention = "@**all**"
@@ -2152,6 +2167,19 @@ class TestMissedMessages(ZulipTestCase):
)
do_change_user_setting(hamlet, "wildcard_mentions_notify", True, acting_user=None)
+ # Topic Wildcard mention should soft reactivate the user
+ with self.soft_deactivate_and_check_long_term_idle(hamlet, expected=False):
+ mention = "@**topic**"
+ stream_mentioned_message_id = self.send_stream_message(othello, "Denmark", mention)
+ handle_missedmessage_emails(
+ hamlet.id,
+ {
+ stream_mentioned_message_id: MissedMessageData(
+ trigger="topic_wildcard_mentioned"
+ ),
+ },
+ )
+
# Stream Wildcard mention should NOT soft reactivate the user
with self.soft_deactivate_and_check_long_term_idle(hamlet, expected=True):
mention = "@**all**"
diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.py
index 9a32f54c486..481a64409d7 100644
--- a/zerver/tests/test_push_notifications.py
+++ b/zerver/tests/test_push_notifications.py
@@ -1690,6 +1690,20 @@ class HandlePushNotificationTest(PushNotificationTest):
self.user_profile, "wildcard_mentions_notify", False, acting_user=None
)
+ # Topic wildcard mention in followed topic should soft reactivate the user
+ # user should be a topic participant
+ self.send_stream_message(self.user_profile, "Denmark", "topic paticipant")
+ with self.soft_deactivate_and_check_long_term_idle(self.user_profile, expected=False):
+ mention = "@**topic**"
+ stream_mentioned_message_id = self.send_stream_message(othello, "Denmark", mention)
+ handle_push_notification(
+ self.user_profile.id,
+ {
+ "message_id": stream_mentioned_message_id,
+ "trigger": "topic_wildcard_mentioned_in_followed_topic",
+ },
+ )
+
# Stream wildcard mention in followed topic should NOT soft reactivate the user
with self.soft_deactivate_and_check_long_term_idle(self.user_profile, expected=True):
mention = "@**all**"
@@ -1713,6 +1727,15 @@ class HandlePushNotificationTest(PushNotificationTest):
self.user_profile, "wildcard_mentions_notify", True, acting_user=None
)
+ # Topic Wildcard mention should soft reactivate the user
+ with self.soft_deactivate_and_check_long_term_idle(self.user_profile, expected=False):
+ mention = "@**topic**"
+ stream_mentioned_message_id = self.send_stream_message(othello, "Denmark", mention)
+ handle_push_notification(
+ self.user_profile.id,
+ {"message_id": stream_mentioned_message_id, "trigger": "topic_wildcard_mentioned"},
+ )
+
# Stream Wildcard mention should NOT soft reactivate the user
with self.soft_deactivate_and_check_long_term_idle(self.user_profile, expected=True):
mention = "@**all**"