push_notification: Remove obsolete fields from APNs payload.

Mobile push notification payloads for APNs no longer contain
the `server` and `realm_id` fields, which were unused.
This commit is contained in:
Prakhar Pratyush
2025-07-30 18:02:33 +05:30
committed by Tim Abbott
parent 124a32e819
commit 1a5cab130d
4 changed files with 16 additions and 21 deletions

View File

@@ -20,6 +20,11 @@ format used by the Zulip server that they are interacting with.
## Changes in Zulip 11.0
**Feature level 413**
* Mobile push notification payloads for APNs no longer contain the
`server` and `realm_id` fields, which were unused.
**Feature level 412**
* [`POST /register`](/api/register-queue),
@@ -43,7 +48,7 @@ format used by the Zulip server that they are interacting with.
* [`POST /register`](/api/register-queue): Added
`max_channel_folder_name_length` and
`max_channel_folder_description_length` fields to the response.
- Mobile push notification payloads for APNs no longer contain the
* Mobile push notification payloads for APNs no longer contain the
`time` field, which was unused.
**Feature level 409**

View File

@@ -977,6 +977,14 @@ def get_base_payload(user_profile: UserProfile) -> dict[str, Any]:
return data
def remove_obsolete_fields_apns(payload: dict[str, Any]) -> None:
# These fields are not used by iOS clients. The legacy
# app requires these in FCM messages, even though we don't
# end up doing anything with them.
payload.pop("server")
payload.pop("realm_id")
def get_message_payload(
user_profile: UserProfile,
message: Message,
@@ -1127,6 +1135,7 @@ def get_message_payload_apns(
zulip_data.update(
message_ids=[message.id],
)
remove_obsolete_fields_apns(zulip_data)
assert message.rendered_content is not None
with override_language(user_profile.default_language):
@@ -1208,6 +1217,7 @@ def get_remove_payload_apns(user_profile: UserProfile, message_ids: list[int]) -
event="remove",
zulip_message_ids=",".join(str(id) for id in message_ids),
)
remove_obsolete_fields_apns(zulip_data)
apns_data = {
"badge": get_apns_badge_count(user_profile, message_ids),
"custom": {"zulip": zulip_data},

View File

@@ -637,8 +637,6 @@ class HandlePushNotificationTest(PushNotificationTestCase):
"badge": 0,
"custom": {
"zulip": {
"server": "testserver",
"realm_id": self.sender.realm.id,
"realm_name": self.sender.realm.name,
"realm_uri": "http://zulip.testserver",
"realm_url": "http://zulip.testserver",
@@ -737,8 +735,6 @@ class HandlePushNotificationTest(PushNotificationTestCase):
"badge": 0,
"custom": {
"zulip": {
"server": "testserver",
"realm_id": self.sender.realm.id,
"realm_name": self.sender.realm.name,
"realm_uri": "http://zulip.testserver",
"realm_url": "http://zulip.testserver",

View File

@@ -1468,8 +1468,6 @@ class TestGetAPNsPayload(PushNotificationTestCase):
"recipient_type": "private",
"sender_email": self.sender.email,
"sender_id": self.sender.id,
"server": settings.EXTERNAL_HOST,
"realm_id": self.sender.realm.id,
"realm_name": self.sender.realm.name,
"realm_uri": self.sender.realm.url,
"realm_url": self.sender.realm.url,
@@ -1510,8 +1508,6 @@ class TestGetAPNsPayload(PushNotificationTestCase):
"recipient_type": "private",
"sender_email": self.sender.email,
"sender_id": self.sender.id,
"server": settings.EXTERNAL_HOST,
"realm_id": self.sender.realm.id,
"realm_name": self.sender.realm.name,
"realm_uri": self.sender.realm.url,
"realm_url": self.sender.realm.url,
@@ -1554,8 +1550,6 @@ class TestGetAPNsPayload(PushNotificationTestCase):
),
"sender_email": self.sender.email,
"sender_id": self.sender.id,
"server": settings.EXTERNAL_HOST,
"realm_id": self.sender.realm.id,
"realm_name": self.sender.realm.name,
"realm_uri": self.sender.realm.url,
"realm_url": self.sender.realm.url,
@@ -1595,8 +1589,6 @@ class TestGetAPNsPayload(PushNotificationTestCase):
"stream": stream.name,
"stream_id": stream.id,
"topic": topic_display_name,
"server": settings.EXTERNAL_HOST,
"realm_id": self.sender.realm.id,
"realm_name": self.sender.realm.name,
"realm_uri": self.sender.realm.url,
"realm_url": self.sender.realm.url,
@@ -1639,8 +1631,6 @@ class TestGetAPNsPayload(PushNotificationTestCase):
"stream": stream.name,
"stream_id": stream.id,
"topic": message.topic_name(),
"server": settings.EXTERNAL_HOST,
"realm_id": self.sender.realm.id,
"realm_name": self.sender.realm.name,
"realm_uri": self.sender.realm.url,
"realm_url": self.sender.realm.url,
@@ -1677,8 +1667,6 @@ class TestGetAPNsPayload(PushNotificationTestCase):
"stream": stream.name,
"stream_id": stream.id,
"topic": message.topic_name(),
"server": settings.EXTERNAL_HOST,
"realm_id": self.sender.realm.id,
"realm_name": self.sender.realm.name,
"realm_uri": self.sender.realm.url,
"realm_url": self.sender.realm.url,
@@ -1716,8 +1704,6 @@ class TestGetAPNsPayload(PushNotificationTestCase):
"stream": stream.name,
"stream_id": stream.id,
"topic": message.topic_name(),
"server": settings.EXTERNAL_HOST,
"realm_id": self.sender.realm.id,
"realm_name": self.sender.realm.name,
"realm_uri": self.sender.realm.url,
"realm_url": self.sender.realm.url,
@@ -1786,8 +1772,6 @@ class TestGetAPNsPayload(PushNotificationTestCase):
"stream": stream.name,
"stream_id": stream.id,
"topic": message.topic_name(),
"server": settings.EXTERNAL_HOST,
"realm_id": hamlet.realm.id,
"realm_name": hamlet.realm.name,
"realm_uri": hamlet.realm.url,
"realm_url": hamlet.realm.url,