From f034a6c3b417012503467395f163bc4a437f18c8 Mon Sep 17 00:00:00 2001 From: Prakhar Pratyush Date: Thu, 7 Aug 2025 16:02:49 +0530 Subject: [PATCH] push_notification: Remove is_removal param from send_push_notifications. We can determine whether the request is meant to revoke an already sent push notification using the "type" field of the payload. Passing `is_removal` parameter explicitly to `send_push_notifications` is not required. --- zerver/lib/push_notifications.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.py index 73e632bec9..c18efa6809 100644 --- a/zerver/lib/push_notifications.py +++ b/zerver/lib/push_notifications.py @@ -1328,7 +1328,7 @@ def handle_remove_push_notification(user_profile_id: int, message_ids: list[int] # for sending mobile notifications, since we don't at this time # know which mobile app version the user may be using. send_push_notifications_legacy(user_profile, apns_payload, gcm_payload, gcm_options) - send_push_notifications(user_profile, payload_data_to_encrypt, is_removal=True) + send_push_notifications(user_profile, payload_data_to_encrypt) # We intentionally use the non-truncated message_ids here. We are # assuming in this very rare case that the user has manually @@ -1463,7 +1463,6 @@ def get_encrypted_data(payload_data_to_encrypt: dict[str, Any], public_key_str: def send_push_notifications( user_profile: UserProfile, payload_data_to_encrypt: dict[str, Any], - is_removal: bool = False, ) -> None: # Uses 'zerver_pushdevice_user_bouncer_device_id_idx' index. push_devices = PushDevice.objects.filter(user=user_profile, bouncer_device_id__isnull=False) @@ -1475,6 +1474,8 @@ def send_push_notifications( ) return + is_removal = payload_data_to_encrypt["type"] == "remove" + # Note: The "Final" qualifier serves as a shorthand # for declaring that a variable is effectively Literal. fcm_priority: Final = "normal" if is_removal else "high"