From 27a450b58d29c24f29a3a6e55f4da3e3fb6a4b5e Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 13 Oct 2017 17:21:38 -0700 Subject: [PATCH] push_notifications: Improve error message for GCM sending issues. This addresses one of the sources of confusion in #6993. --- zerver/lib/push_notifications.py | 3 ++- zerver/tests/test_push_notifications.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.py index 0dafe87166..45321680c1 100644 --- a/zerver/lib/push_notifications.py +++ b/zerver/lib/push_notifications.py @@ -155,7 +155,8 @@ def send_android_push_notification_to_user(user_profile, data): def send_android_push_notification(devices, data, remote=False): # type: (List[DeviceToken], Dict[str, Any], bool) -> None if not gcm: - logging.warning("Attempting to send a GCM push notification, but no API key was configured") + logging.warning("Skipping sending a GCM push notification since " + "PUSH_NOTIFICATION_BOUNCER_URL and ANDROID_GCM_API_KEY are both unset") return reg_ids = [device.token for device in devices] diff --git a/zerver/tests/test_push_notifications.py b/zerver/tests/test_push_notifications.py index 91300d733b..b057e5709b 100644 --- a/zerver/tests/test_push_notifications.py +++ b/zerver/tests/test_push_notifications.py @@ -965,9 +965,9 @@ class GCMNotSetTest(GCMTest): # type: (mock.MagicMock) -> None apn.gcm = None apn.send_android_push_notification_to_user(self.user_profile, {}) - mock_warning.assert_called_with("Attempting to send a GCM push " - "notification, but no API key was " - "configured") + mock_warning.assert_called_with( + "Skipping sending a GCM push notification since PUSH_NOTIFICATION_BOUNCER_URL " + "and ANDROID_GCM_API_KEY are both unset") class GCMIOErrorTest(GCMTest): @mock.patch('zerver.lib.push_notifications.gcm.json_request')