mirror of https://github.com/zulip/zulip.git
notifications: Fix 'get_gcm_alert' and 'get_apns_alert_subtitle'.
The 'get_gcm_alert' and 'get_apns_alert_subtitle' functions don't include the case when the trigger is 'NotificationTriggers.FOLLOWED_TOPIC_WILDCARD_MENTION'. This commit updates the functions to include 'NotificationTriggers.FOLLOWED_TOPIC_WILDCARD_MENTION'.
This commit is contained in:
parent
5f6dd83696
commit
0bf6eb6786
|
@ -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:
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue