mirror of https://github.com/zulip/zulip.git
push notifs: Include same stream and sender info on GCM as on APNs.
This takes the information added to APNs payloads by #7080, and adds to our GCM payloads the parts that it didn't already have.
This commit is contained in:
parent
e077d6fc74
commit
014900c2e5
|
@ -440,13 +440,22 @@ def truncate_content(content: Text) -> Text:
|
|||
|
||||
def get_common_payload(message: Message) -> Dict[str, Any]:
|
||||
data = {} # type: Dict[str, Any]
|
||||
|
||||
# These will let the app support logging into multiple realms and servers.
|
||||
data['server'] = settings.EXTERNAL_HOST
|
||||
data['realm_id'] = message.sender.realm.id
|
||||
|
||||
# `sender_id` is preferred, but some existing versions use `sender_email`.
|
||||
data['sender_id'] = message.sender.id
|
||||
data['sender_email'] = message.sender.email
|
||||
|
||||
if message.is_stream_message():
|
||||
data['recipient_type'] = "stream"
|
||||
data['stream'] = get_display_recipient(message.recipient)
|
||||
data['topic'] = message.subject
|
||||
else:
|
||||
data['recipient_type'] = "private"
|
||||
|
||||
return data
|
||||
|
||||
def get_apns_payload(message: Message) -> Dict[str, Any]:
|
||||
|
@ -456,9 +465,6 @@ def get_apns_payload(message: Message) -> Dict[str, Any]:
|
|||
zulip_data = get_common_payload(message)
|
||||
zulip_data.update({
|
||||
'message_ids': [message.id],
|
||||
'sender_id': message.sender.id,
|
||||
'server': settings.EXTERNAL_HOST,
|
||||
'realm_id': message.sender.realm.id,
|
||||
})
|
||||
|
||||
apns_data = {
|
||||
|
|
|
@ -750,6 +750,9 @@ class TestGetGCMPayload(PushNotificationTest):
|
|||
"time": apn.datetime_to_timestamp(message.pub_date),
|
||||
"content": 'a' * 200 + '…',
|
||||
"content_truncated": True,
|
||||
"server": settings.EXTERNAL_HOST,
|
||||
"realm_id": self.example_user("hamlet").realm.id,
|
||||
"sender_id": self.example_user("hamlet").id,
|
||||
"sender_email": self.example_email("hamlet"),
|
||||
"sender_full_name": "King Hamlet",
|
||||
"sender_avatar_url": apn.absolute_avatar_url(message.sender),
|
||||
|
@ -772,6 +775,9 @@ class TestGetGCMPayload(PushNotificationTest):
|
|||
"time": apn.datetime_to_timestamp(message.pub_date),
|
||||
"content": message.content,
|
||||
"content_truncated": False,
|
||||
"server": settings.EXTERNAL_HOST,
|
||||
"realm_id": self.example_user("hamlet").realm.id,
|
||||
"sender_id": self.example_user("hamlet").id,
|
||||
"sender_email": self.example_email("hamlet"),
|
||||
"sender_full_name": "King Hamlet",
|
||||
"sender_avatar_url": apn.absolute_avatar_url(message.sender),
|
||||
|
@ -793,6 +799,9 @@ class TestGetGCMPayload(PushNotificationTest):
|
|||
"time": apn.datetime_to_timestamp(message.pub_date),
|
||||
"content": message.content,
|
||||
"content_truncated": False,
|
||||
"server": settings.EXTERNAL_HOST,
|
||||
"realm_id": self.example_user("hamlet").realm.id,
|
||||
"sender_id": self.example_user("hamlet").id,
|
||||
"sender_email": self.example_email("hamlet"),
|
||||
"sender_full_name": "King Hamlet",
|
||||
"sender_avatar_url": apn.absolute_avatar_url(message.sender),
|
||||
|
@ -817,6 +826,9 @@ class TestGetGCMPayload(PushNotificationTest):
|
|||
"time": apn.datetime_to_timestamp(message.pub_date),
|
||||
"content": "***REDACTED***",
|
||||
"content_truncated": False,
|
||||
"server": settings.EXTERNAL_HOST,
|
||||
"realm_id": self.example_user("hamlet").realm.id,
|
||||
"sender_id": self.example_user("hamlet").id,
|
||||
"sender_email": self.example_email("hamlet"),
|
||||
"sender_full_name": "King Hamlet",
|
||||
"sender_avatar_url": apn.absolute_avatar_url(message.sender),
|
||||
|
|
Loading…
Reference in New Issue