mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
push_notifications: Redact content for older clients if E2EE required.
This commit replaces the `PUSH_NOTIFICATION_REDACT_CONTENT` server setting with `require_e2ee_push_notifications` realm setting. If `require_e2ee_push_notifications` set to True: * Older clients: Content redacted * Updated clients: Encrypted content If `require_e2ee_push_notifications` set to False: * Older clients: Content NOT redacted * Updated clients: Encrypted content Note: Older clients refers to clients that don't support E2EE. Fixes part of #35370.
This commit is contained in:
committed by
Tim Abbott
parent
fc6cd9a966
commit
d972bb1ca9
@@ -971,9 +971,6 @@ def get_mobile_push_content(rendered_content: str) -> str:
|
||||
else:
|
||||
child.getparent().replace(child, collapse_element)
|
||||
|
||||
if settings.PUSH_NOTIFICATION_REDACT_CONTENT:
|
||||
return _("New message")
|
||||
|
||||
elem = lxml.html.fragment_fromstring(rendered_content, create_parent=True)
|
||||
change_katex_to_raw_latex(elem)
|
||||
potentially_collapse_quotes(elem)
|
||||
@@ -1324,6 +1321,18 @@ def send_push_notifications_legacy(
|
||||
)
|
||||
return
|
||||
|
||||
# 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:
|
||||
# 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 uses_notification_bouncer():
|
||||
send_notifications_to_bouncer(
|
||||
user_profile, apns_payload, gcm_payload, gcm_options, android_devices, apple_devices
|
||||
|
||||
Reference in New Issue
Block a user