Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
push_notification: Remove 'modernize_apns_payload'.
Prakhar Pratyush298a39e45720
diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.pyindex 6eeb42f6551..12991ec6e8a 100644--- a/zerver/lib/push_notifications.py+++ b/zerver/lib/push_notifications.py@@ -212,32 +212,6 @@ def get_apns_context() -> APNsContext | None:return APNsContext(apns=apns, loop=loop)-def modernize_apns_payload(data: Mapping[str, Any]) -> Mapping[str, Any]:- """Take a payload in an unknown Zulip version's format, and return in current format."""- # TODO this isn't super robust as is -- if a buggy remote server- # sends a malformed payload, we are likely to raise an exception.- if "message_ids" in data:- # The format sent by 1.6.0, from the earliest pre-1.6.0- # version with bouncer support up until 613d093d7 pre-1.7.0:- # 'alert': str, # just sender, and text about direct message/mention- # 'message_ids': List[int], # always just one- return {- "alert": data["alert"],- "badge": 0,- "custom": {- "zulip": {- "message_ids": data["message_ids"],- },- },- }- else:- # Something already compatible with the current format.- # `alert` may be a string, or a dict with `title` and `body`.- # In 1.7.0 and 1.7.1, before 0912b5ba8 pre-1.8.0, the only- # item in `custom.zulip` is `message_ids`.- return data--APNS_MAX_RETRIES = 3@@ -339,7 +313,7 @@ def send_apple_push_notification(len(devices),num_duplicate_tokens,)- payload_data = dict(modernize_apns_payload(payload_data))+ payload_data = dict(payload_data)message = {**payload_data.pop("custom", {}), "aps": payload_data}have_missing_app_id = Falsediff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.pyindex b734e9a237f..d4b42973470 100644--- a/zerver/tests/test_push_notifications.py+++ b/zerver/tests/test_push_notifications.py@@ -38,7 +38,6 @@ from zerver.lib.push_notifications import (get_message_payload_apns,get_message_payload_gcm,get_mobile_push_content,- modernize_apns_payload,parse_fcm_options,send_android_push_notification_to_user,send_apple_push_notification,@@ -1477,20 +1476,6 @@ class TestAPNs(PushNotificationTestCase):logger.output,)- def test_modernize_apns_payload(self) -> None:- payload = {- "alert": "Message from Hamlet",- "badge": 0,- "custom": {"zulip": {"message_ids": [3]}},- }- self.assertEqual(- modernize_apns_payload(- {"alert": "Message from Hamlet", "message_ids": [3], "badge": 0}- ),- payload,- )- self.assertEqual(modernize_apns_payload(payload), payload)-@mock.patch("zerver.lib.push_notifications.push_notifications_configured", return_value=True)def test_apns_badge_count(self, mock_push_notifications: mock.MagicMock) -> None:user_profile = self.example_user("othello")