mirror of
https://github.com/zulip/zulip.git
synced 2025-11-23 16:01:24 +00:00
push_notification: Improve logged message when apns_context is None.
Earlier, while sending notification if `apns_context=None` - we logged: "APNs: Dropping a notification because nothing configured. Set ZULIP_SERVICES_URL (or APNS_CERT_FILE)." which is not accurate for E2EE case. For the non-E2EE case it is correct because configuring ZULIP_SERVICES_URL results in transfering the responsbility to make API call to APNs to the bouncer. Or they can configure APNS_CERT_FILE if they want to send directly. In E2EE case, the `send_e2ee_push_notification_apple` is part of bouncer so configuring `ZULIP_SERVICES_URL` doesn't help. One needs to configure either `APNS_TOKEN_KEY_FILE` or `APNS_CERT_FILE`. Message to log is updated accordingly + severity increased from DEBUG to ERROR. Signed-off-by: Prakhar Pratyush <prakhar@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
d893496de1
commit
25630f316b
@@ -221,7 +221,7 @@ class SendPushNotificationTest(E2EEPushNotificationTestCase):
|
||||
self.mock_fcm() as mock_fcm_messaging,
|
||||
mock.patch("zilencer.lib.push_notifications.get_apns_context", return_value=None),
|
||||
self.assertLogs("zerver.lib.push_notifications", level="INFO") as zerver_logger,
|
||||
self.assertLogs("zilencer.lib.push_notifications", level="DEBUG") as zilencer_logger,
|
||||
self.assertLogs("zilencer.lib.push_notifications", level="WARNING") as zilencer_logger,
|
||||
mock.patch("time.perf_counter", side_effect=[10.0, 12.0]),
|
||||
):
|
||||
mock_fcm_messaging.send_each.return_value = self.make_fcm_error_response(
|
||||
@@ -238,9 +238,8 @@ class SendPushNotificationTest(E2EEPushNotificationTestCase):
|
||||
zerver_logger.output[0],
|
||||
)
|
||||
self.assertEqual(
|
||||
"DEBUG:zilencer.lib.push_notifications:"
|
||||
"APNs: Dropping a notification because nothing configured. "
|
||||
"Set ZULIP_SERVICES_URL (or APNS_CERT_FILE).",
|
||||
"ERROR:zilencer.lib.push_notifications:"
|
||||
"APNs: Dropping push notifications since neither APNS_TOKEN_KEY_FILE nor APNS_CERT_FILE is set.",
|
||||
zilencer_logger.output[0],
|
||||
)
|
||||
self.assertIn(
|
||||
|
||||
@@ -40,9 +40,9 @@ def send_e2ee_push_notification_apple(
|
||||
apns_context = get_apns_context()
|
||||
|
||||
if apns_context is None:
|
||||
logger.debug(
|
||||
"APNs: Dropping a notification because nothing configured. "
|
||||
"Set ZULIP_SERVICES_URL (or APNS_CERT_FILE)."
|
||||
logger.error(
|
||||
"APNs: Dropping push notifications since "
|
||||
"neither APNS_TOKEN_KEY_FILE nor APNS_CERT_FILE is set."
|
||||
)
|
||||
return SentPushNotificationResult(
|
||||
successfully_sent_count=successfully_sent_count,
|
||||
|
||||
Reference in New Issue
Block a user