mirror of
https://github.com/zulip/zulip.git
synced 2025-11-17 12:21:58 +00:00
push_notifications: Fix error while sending legacy notification.
While sending push notifications for a user in realm with `require_e2ee_push_notifications=true` and no iOS device registered, it resulted in an error. Also, while sending notif to revoke in realm with `require_e2ee_push_notifications=true` and no android device registered, it resulted in an error. This commit fixes the bug by improving the checks to apply the redact logic only if android/iOS device is registered and it's not a remove event. Co-authored-by: Tim Abbott <tabbott@zulip.com> Signed-off-by: Prakhar Pratyush <prakhar@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
71a89be0a9
commit
048b4a6ddf
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user