Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

push_notifications: Fix error while sending legacy notification.

Prakhar Pratyush048b4a6ddf32
diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.py
index e567b748bd4..099e82656f3 100644
--- a/zerver/lib/push_notifications.py
+++ b/zerver/lib/push_notifications.py
@@ -1370,14 +1370,15 @@ def send_push_notifications_legacy(
# While sending push notifications for new messages to older clients
# (which don't support E2EE), if `require_e2ee_push_notifications`
# realm setting is set to `true`, we redact the content.
- if gcm_payload.get("event") != "remove" and user_profile.realm.require_e2ee_push_notifications:
+ if user_profile.realm.require_e2ee_push_notifications:
# Make deep copies so redaction doesn't affect the original dicts
- apns_payload = copy.deepcopy(apns_payload)
- gcm_payload = copy.deepcopy(gcm_payload)
-
placeholder_content = _("New message")
- apns_payload["alert"]["body"] = placeholder_content
- gcm_payload["content"] = placeholder_content
+ if gcm_payload and gcm_payload.get("event") != "remove":
+ gcm_payload = copy.deepcopy(gcm_payload)
+ gcm_payload["content"] = placeholder_content
+ if apns_payload and apns_payload["custom"]["zulip"].get("event") != "remove":
+ apns_payload = copy.deepcopy(apns_payload)
+ apns_payload["alert"]["body"] = placeholder_content
if uses_notification_bouncer():
send_notifications_to_bouncer(