diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.py index 030fab6719..900ef5b6a6 100644 --- a/zerver/lib/push_notifications.py +++ b/zerver/lib/push_notifications.py @@ -672,6 +672,11 @@ def get_gcm_alert( return f"{sender_str} mentioned you in #{display_recipient}" else: return f"{sender_str} mentioned @{mentioned_user_group_name} in #{display_recipient}" + elif ( + message.is_stream_message() + and trigger == NotificationTriggers.FOLLOWED_TOPIC_WILDCARD_MENTION + ): + return "TODO" elif message.is_stream_message() and trigger == NotificationTriggers.WILDCARD_MENTION: return f"{sender_str} mentioned everyone in #{display_recipient}" else: @@ -837,6 +842,8 @@ def get_apns_alert_subtitle( ) else: return _("{full_name} mentioned you:").format(full_name=message.sender.full_name) + elif trigger == NotificationTriggers.FOLLOWED_TOPIC_WILDCARD_MENTION: + return _("TODO") elif trigger == NotificationTriggers.WILDCARD_MENTION: return _("{full_name} mentioned everyone:").format(full_name=message.sender.full_name) elif message.recipient.type == Recipient.PERSONAL: diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.py index 8d087ea084..4ebfb18eb8 100644 --- a/zerver/tests/test_push_notifications.py +++ b/zerver/tests/test_push_notifications.py @@ -2058,6 +2058,39 @@ class TestGetAPNsPayload(PushNotificationTest): } self.assertDictEqual(payload, expected) + def test_get_message_payload_apns_followed_topic_wildcard_mention(self) -> None: + user_profile = self.example_user("othello") + stream = Stream.objects.filter(name="Verona").get() + message = self.get_message(Recipient.STREAM, stream.id, stream.realm_id) + payload = get_message_payload_apns( + user_profile, message, NotificationTriggers.FOLLOWED_TOPIC_WILDCARD_MENTION + ) + expected = { + "alert": { + "title": "#Verona > Test topic", + "subtitle": "TODO", + "body": message.content, + }, + "sound": "default", + "badge": 0, + "custom": { + "zulip": { + "message_ids": [message.id], + "recipient_type": "stream", + "sender_email": self.sender.email, + "sender_id": self.sender.id, + "stream": get_display_recipient(message.recipient), + "stream_id": stream.id, + "topic": message.topic_name(), + "server": settings.EXTERNAL_HOST, + "realm_id": self.sender.realm.id, + "realm_uri": self.sender.realm.uri, + "user_id": user_profile.id, + }, + }, + } + self.assertDictEqual(payload, expected) + def test_get_message_payload_apns_stream_wildcard_mention(self) -> None: user_profile = self.example_user("othello") stream = Stream.objects.filter(name="Verona").get() @@ -2198,6 +2231,9 @@ class TestGetGCMPayload(PushNotificationTest): mentioned_user_group_name="mobile_team", ) + def test_get_message_payload_gcm_followed_topic_wildcard_mention(self) -> None: + self._test_get_message_payload_gcm_mentions("followed_topic_wildcard_mentioned", "TODO") + 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"