Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
android notifications: Differentiate personal vs wildcard mentions.
Abhijeet Prasad Bodas4d24499317dd
diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.pyindex 4d0edb97c3f..578edb6601c 100644--- a/zerver/lib/push_notifications.py+++ b/zerver/lib/push_notifications.py@@ -554,17 +554,18 @@ def get_gcm_alert(message: Message) -> str:Determine what alert string to display based on the missed messages."""sender_str = message.sender.full_name+ display_recipient = get_display_recipient(message.recipient)if message.recipient.type == Recipient.HUDDLE and message.trigger == "private_message":return f"New private group message from {sender_str}"elif message.recipient.type == Recipient.PERSONAL and message.trigger == "private_message":return f"New private message from {sender_str}"- elif message.is_stream_message() and (- message.trigger == "mentioned" or message.trigger == "wildcard_mentioned"- ):- return f"New mention from {sender_str}"+ elif message.is_stream_message() and message.trigger == "mentioned":+ return f"{sender_str} mentioned you in #{display_recipient}"+ elif message.is_stream_message() and message.trigger == "wildcard_mentioned":+ return f"{sender_str} mentioned everyone in #{display_recipient}"else:assert message.is_stream_message() and message.trigger == "stream_push_notify"- return f"New stream message from {sender_str} in {get_display_recipient(message.recipient)}"+ return f"New stream message from {sender_str} in #{display_recipient}"def get_mobile_push_content(rendered_content: str) -> str:diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.pyindex c253974d9bc..07eeab293da 100644--- a/zerver/tests/test_push_notifications.py+++ b/zerver/tests/test_push_notifications.py@@ -1740,13 +1740,13 @@ class TestGetAPNsPayload(PushNotificationTest):class TestGetGCMPayload(PushNotificationTest):- def test_get_message_payload_gcm(self) -> None:+ def _test_get_message_payload_gcm_mentions(self, trigger: str, alert: str) -> None:stream = Stream.objects.filter(name="Verona").get()message = self.get_message(Recipient.STREAM, stream.id)message.content = "a" * 210message.rendered_content = "a" * 210message.save()- message.trigger = "mentioned"+ message.trigger = triggerhamlet = self.example_user("hamlet")payload, gcm_options = get_message_payload_gcm(hamlet, message)@@ -1755,7 +1755,7 @@ class TestGetGCMPayload(PushNotificationTest):{"user_id": hamlet.id,"event": "message",- "alert": "New mention from King Hamlet",+ "alert": alert,"zulip_message_id": message.id,"time": datetime_to_timestamp(message.date_sent),"content": "a" * 200 + "…",@@ -1779,7 +1779,17 @@ class TestGetGCMPayload(PushNotificationTest):},)- def test_get_message_payload_gcm_personal(self) -> None:+ def test_get_message_payload_gcm_personal_mention(self) -> None:+ self._test_get_message_payload_gcm_mentions(+ "mentioned", "King Hamlet mentioned you in #Verona"+ )++ def test_get_message_payload_gcm_wildcard_mention(self) -> None:+ self._test_get_message_payload_gcm_mentions(+ "wildcard_mentioned", "King Hamlet mentioned everyone in #Verona"+ )++ def test_get_message_payload_gcm_private_message(self) -> None:message = self.get_message(Recipient.PERSONAL, 1)message.trigger = "private_message"hamlet = self.example_user("hamlet")@@ -1823,7 +1833,7 @@ class TestGetGCMPayload(PushNotificationTest):{"user_id": hamlet.id,"event": "message",- "alert": "New stream message from King Hamlet in Denmark",+ "alert": "New stream message from King Hamlet in #Denmark","zulip_message_id": message.id,"time": datetime_to_timestamp(message.date_sent),"content": message.content,@@ -1860,7 +1870,7 @@ class TestGetGCMPayload(PushNotificationTest):{"user_id": hamlet.id,"event": "message",- "alert": "New stream message from King Hamlet in Denmark",+ "alert": "New stream message from King Hamlet in #Denmark","zulip_message_id": message.id,"time": datetime_to_timestamp(message.date_sent),"content": "*This organization has disabled including message content in mobile push notifications*",