push_notifs: Rename parse_gcm_options to parse_fcm_options.

This commit is contained in:
Mateusz Mandera 2024-06-13 21:24:17 +02:00 committed by Tim Abbott
parent 497be370f5
commit 297141f8c4
2 changed files with 11 additions and 11 deletions

View File

@ -402,7 +402,7 @@ def send_android_push_notification_to_user(
)
def parse_gcm_options(options: Dict[str, Any], data: Dict[str, Any]) -> str:
def parse_fcm_options(options: Dict[str, Any], data: Dict[str, Any]) -> str:
"""
Parse FCM options, supplying defaults, and raising an error if invalid.
@ -463,7 +463,7 @@ def send_android_push_notification(
data: The JSON object (decoded) to send as the 'data' parameter of
the FCM message.
options: Additional options to control the FCM message sent.
For details, see `parse_gcm_options`.
For details, see `parse_fcm_options`.
"""
if not devices:
return 0
@ -486,7 +486,7 @@ def send_android_push_notification(
"GCM: Sending notification for local user %s to %d devices", user_identity, len(devices)
)
reg_ids = [device.token for device in devices]
priority = parse_gcm_options(options, data)
priority = parse_fcm_options(options, data)
try:
# See https://firebase.google.com/docs/cloud-messaging/http-server-ref .
# Two kwargs `retries` and `session` get eaten by `json_request`;

View File

@ -59,7 +59,7 @@ from zerver.lib.push_notifications import (
handle_remove_push_notification,
hex_to_b64,
modernize_apns_payload,
parse_gcm_options,
parse_fcm_options,
send_android_push_notification_to_user,
send_apple_push_notification,
send_notifications_to_bouncer,
@ -4773,20 +4773,20 @@ class TestPushApi(BouncerTestCase):
class GCMParseOptionsTest(ZulipTestCase):
def test_invalid_option(self) -> None:
with self.assertRaises(JsonableError):
parse_gcm_options({"invalid": True}, {})
parse_fcm_options({"invalid": True}, {})
def test_invalid_priority_value(self) -> None:
with self.assertRaises(JsonableError):
parse_gcm_options({"priority": "invalid"}, {})
parse_fcm_options({"priority": "invalid"}, {})
def test_default_priority(self) -> None:
self.assertEqual("high", parse_gcm_options({}, {"event": "message"}))
self.assertEqual("normal", parse_gcm_options({}, {"event": "remove"}))
self.assertEqual("normal", parse_gcm_options({}, {}))
self.assertEqual("high", parse_fcm_options({}, {"event": "message"}))
self.assertEqual("normal", parse_fcm_options({}, {"event": "remove"}))
self.assertEqual("normal", parse_fcm_options({}, {}))
def test_explicit_priority(self) -> None:
self.assertEqual("normal", parse_gcm_options({"priority": "normal"}, {}))
self.assertEqual("high", parse_gcm_options({"priority": "high"}, {}))
self.assertEqual("normal", parse_fcm_options({"priority": "normal"}, {}))
self.assertEqual("high", parse_fcm_options({"priority": "high"}, {}))
@mock.patch("zerver.lib.push_notifications.gcm_client")