notifications: Include realm_uri in push notifications.

This should make it much simpler for the mobile apps to line up the
data from server_settings against the data in the notifications.

Addresses part of #10094.
This commit is contained in:
Tim Abbott
2018-08-01 15:44:40 -07:00
parent 58ee3fa8c4
commit 5f8d193bb7
2 changed files with 8 additions and 0 deletions

View File

@@ -497,6 +497,7 @@ def get_common_payload(message: Message) -> 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
data['realm_uri'] = message.sender.realm.uri
# `sender_id` is preferred, but some existing versions use `sender_email`.
data['sender_id'] = message.sender.id

View File

@@ -744,6 +744,7 @@ class TestGetAPNsPayload(PushNotificationTest):
'sender_id': 4,
'server': settings.EXTERNAL_HOST,
'realm_id': message.sender.realm.id,
'realm_uri': message.sender.realm.uri,
}
}
}
@@ -772,6 +773,7 @@ class TestGetAPNsPayload(PushNotificationTest):
"topic": message.subject,
'server': settings.EXTERNAL_HOST,
'realm_id': message.sender.realm.id,
'realm_uri': message.sender.realm.uri,
}
}
}
@@ -803,6 +805,7 @@ class TestGetAPNsPayload(PushNotificationTest):
'sender_id': 4,
'server': settings.EXTERNAL_HOST,
'realm_id': message.sender.realm.id,
'realm_uri': message.sender.realm.uri,
}
}
}
@@ -829,6 +832,7 @@ class TestGetGCMPayload(PushNotificationTest):
"content_truncated": True,
"server": settings.EXTERNAL_HOST,
"realm_id": self.example_user("hamlet").realm.id,
"realm_uri": self.example_user("hamlet").realm.uri,
"sender_id": self.example_user("hamlet").id,
"sender_email": self.example_email("hamlet"),
"sender_full_name": "King Hamlet",
@@ -854,6 +858,7 @@ class TestGetGCMPayload(PushNotificationTest):
"content_truncated": False,
"server": settings.EXTERNAL_HOST,
"realm_id": self.example_user("hamlet").realm.id,
"realm_uri": self.example_user("hamlet").realm.uri,
"sender_id": self.example_user("hamlet").id,
"sender_email": self.example_email("hamlet"),
"sender_full_name": "King Hamlet",
@@ -878,6 +883,7 @@ class TestGetGCMPayload(PushNotificationTest):
"content_truncated": False,
"server": settings.EXTERNAL_HOST,
"realm_id": self.example_user("hamlet").realm.id,
"realm_uri": self.example_user("hamlet").realm.uri,
"sender_id": self.example_user("hamlet").id,
"sender_email": self.example_email("hamlet"),
"sender_full_name": "King Hamlet",
@@ -905,6 +911,7 @@ class TestGetGCMPayload(PushNotificationTest):
"content_truncated": False,
"server": settings.EXTERNAL_HOST,
"realm_id": self.example_user("hamlet").realm.id,
"realm_uri": self.example_user("hamlet").realm.uri,
"sender_id": self.example_user("hamlet").id,
"sender_email": self.example_email("hamlet"),
"sender_full_name": "King Hamlet",