Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
push_notifications: Don't send "alert" in remove APNs payload.
Chris Bobbee49180062122
diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.pyindex 7a7ca38e01f..bfd37ede2c6 100644--- a/zerver/lib/push_notifications.py+++ b/zerver/lib/push_notifications.py@@ -6,7 +6,7 @@ import loggingimport reimport timefrom collections.abc import Callable, Mapping, Sequence-from dataclasses import asdict, dataclass, field+from dataclasses import asdict, dataclassfrom email.headerregistry import Addressfrom functools import cachefrom typing import TYPE_CHECKING, Any, Final, Literal, Optional, TypeAlias, Union, cast@@ -1452,9 +1452,7 @@ class APNsHTTPHeaders:@dataclassclass APNsPayload(PushRequestBasePayload):- aps: dict[str, int | dict[str, str]] = field(- default_factory=lambda: {"mutable-content": 1, "alert": {"title": "New notification"}}- )+ aps: dict[str, int | dict[str, str]]@dataclass@@ -1520,9 +1518,13 @@ def send_push_notifications(apns_priority=apns_priority,apns_push_type=apns_push_type,)+ aps: dict[str, int | dict[str, str]] = {"mutable-content": 1}+ if not is_removal:+ aps["alert"] = {"title": "New notification"}apns_payload = APNsPayload(push_key_id=push_device.push_key_id,encrypted_data=encrypted_data,+ aps=aps,)apns_push_request = APNsPushRequest(token_id=b64encode_token_id_int(push_device.push_token_id),diff --git a/zerver/tests/test_e2ee_push_notifications.py b/zerver/tests/test_e2ee_push_notifications.pyindex b4e561337c5..fea5e9d9149 100644--- a/zerver/tests/test_e2ee_push_notifications.py+++ b/zerver/tests/test_e2ee_push_notifications.py@@ -67,6 +67,12 @@ class SendPushNotificationTest(E2EEPushNotificationTestCase):mock_fcm_messaging.send_each.assert_called_once()send_notification.assert_called_once()+ apns_message = send_notification.call_args.args[0].message+ self.assertEqual(+ apns_message["aps"],+ {"mutable-content": 1, "alert": {"title": "New notification"}},+ )+self.assertEqual("INFO:zerver.lib.push_notifications:"f"Sending push notifications to mobile clients for user {hamlet.id}",@@ -872,6 +878,9 @@ class RemovePushNotificationTest(E2EEPushNotificationTestCase):mock_fcm_messaging.send_each.assert_called_once()send_notification.assert_called_once()+ apns_message = send_notification.call_args.args[0].message+ self.assertEqual(apns_message["aps"], {"mutable-content": 1})+user_message.refresh_from_db()self.assertFalse(user_message.flags.active_mobile_push_notification)