From a20b454ebb32a4444a2f6b204e72459eefe96fde Mon Sep 17 00:00:00 2001 From: Aditya Bajaj <72880238+AdityaB4@users.noreply.github.com> Date: Sat, 23 Mar 2024 00:37:51 +0800 Subject: [PATCH] notifications: Shorten string for redacted content. Replace the long string for organisations that have notification body/content disabled (settings.PUSH_NOTIFICATION_REDACT_CONTENT set to true) with "New message". This allows more of the limited space on the mobile device screen to be used for additional messages rather than this verbose content. Fixes #29152 --- zerver/lib/push_notifications.py | 8 +------- zerver/tests/test_push_notifications.py | 4 ++-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.py index 55406642f2..e43b403b88 100644 --- a/zerver/lib/push_notifications.py +++ b/zerver/lib/push_notifications.py @@ -922,13 +922,7 @@ def get_mobile_push_content(rendered_content: str) -> str: return plain_text if settings.PUSH_NOTIFICATION_REDACT_CONTENT: - return ( - "*" - + _( - "This organization has disabled including message content in mobile push notifications" - ) - + "*" - ) + return _("New message") elem = lxml.html.fragment_fromstring(rendered_content, create_parent=True) change_katex_to_raw_latex(elem) diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.py index 6ccb416b32..f5343669cc 100644 --- a/zerver/tests/test_push_notifications.py +++ b/zerver/tests/test_push_notifications.py @@ -4109,7 +4109,7 @@ class TestGetAPNsPayload(PushNotificationTest): "alert": { "title": "Cordelia, Lear's daughter, King Hamlet, Othello, the Moor of Venice", "subtitle": "King Hamlet:", - "body": "*This organization has disabled including message content in mobile push notifications*", + "body": "New message", }, "sound": "default", "badge": 0, @@ -4305,7 +4305,7 @@ class TestGetGCMPayload(PushNotificationTest): "event": "message", "zulip_message_id": message.id, "time": datetime_to_timestamp(message.date_sent), - "content": "*This organization has disabled including message content in mobile push notifications*", + "content": "New message", "content_truncated": False, "server": settings.EXTERNAL_HOST, "realm_id": hamlet.realm.id,