mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 16:37:23 +00:00
push-notifications: Update payload for realm name and event string.
Adds `user.realm.string_id` as the realm name to the base payload for notifications. Uses this realm name in the body of the alert in the `apns_data`. Changes the event string from "test-by-device-token" to "test". Fixes #28075.
This commit is contained in:
committed by
Tim Abbott
parent
2165486c88
commit
a018f2611b
@@ -915,6 +915,7 @@ def get_base_payload(user_profile: UserProfile) -> Dict[str, Any]:
|
||||
data["server"] = settings.EXTERNAL_HOST
|
||||
data["realm_id"] = user_profile.realm.id
|
||||
data["realm_uri"] = user_profile.realm.uri
|
||||
data["realm_name"] = user_profile.realm.name
|
||||
data["user_id"] = user_profile.id
|
||||
|
||||
return data
|
||||
@@ -1405,7 +1406,7 @@ def send_test_push_notification_directly_to_devices(
|
||||
remote: Optional["RemoteZulipServer"] = None,
|
||||
) -> None:
|
||||
payload = copy.deepcopy(base_payload)
|
||||
payload["event"] = "test-by-device-token"
|
||||
payload["event"] = "test"
|
||||
|
||||
apple_devices = [device for device in devices if device.kind == PushDeviceToken.APNS]
|
||||
android_devices = [device for device in devices if device.kind == PushDeviceToken.GCM]
|
||||
@@ -1415,10 +1416,13 @@ def send_test_push_notification_directly_to_devices(
|
||||
android_payload = copy.deepcopy(payload)
|
||||
|
||||
realm_uri = base_payload["realm_uri"]
|
||||
realm_name = base_payload["realm_name"]
|
||||
apns_data = {
|
||||
"alert": {
|
||||
"title": _("Test notification"),
|
||||
"body": _("This is a test notification from {realm_uri}.").format(realm_uri=realm_uri),
|
||||
"body": _("This is a test notification from {realm_name} ({realm_uri}).").format(
|
||||
realm_name=realm_name, realm_uri=realm_uri
|
||||
),
|
||||
},
|
||||
"sound": "default",
|
||||
"custom": {"zulip": apple_payload},
|
||||
|
||||
Reference in New Issue
Block a user