Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
push events: Use DeviceUpdateEvent pydantic type.
Evy Kassirer4b0e67cf7ac1
diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.pyindex 442cfcf2713..c821d7bf246 100644--- a/zerver/lib/push_notifications.py+++ b/zerver/lib/push_notifications.py@@ -41,6 +41,7 @@ from zerver.lib.avatar import absolute_avatar_url, get_avatar_for_inaccessible_ufrom zerver.lib.devices import b64decode_token_id_base64, b64encode_token_id_intfrom zerver.lib.display_recipient import get_display_recipientfrom zerver.lib.emoji_utils import hex_codepoint_to_emoji+from zerver.lib.event_types import DeviceUpdateEventfrom zerver.lib.exceptions import ErrorCode, JsonableError, MissingRemoteRealmErrorfrom zerver.lib.message import (OnlyMessageFields,@@ -1591,12 +1592,7 @@ def send_push_notifications(user=user_profile, push_token_id__in=delete_token_ids_int)for push_device in push_devices:- event = dict(- type="device",- op="update",- device_id=push_device.id,- push_token_id=None,- )+ event = DeviceUpdateEvent(device_id=push_device.id, push_token_id=None)send_event_on_commit(user_profile.realm, event, [user_profile.id])push_devices.update(push_token_id=None)diff --git a/zerver/lib/push_registration.py b/zerver/lib/push_registration.pyindex fac84b77c67..ab931e9e302 100644--- a/zerver/lib/push_registration.py+++ b/zerver/lib/push_registration.py@@ -8,6 +8,7 @@ from django.conf import settingsfrom django.utils.translation import gettext as _from zerver.lib.devices import b64decode_token_id_base64+from zerver.lib.event_types import DeviceUpdateEventfrom zerver.lib.exceptions import (InvalidBouncerPublicKeyError,InvalidEncryptedPushRegistrationError,@@ -55,12 +56,7 @@ def handle_registration_to_bouncer_failure(the `/register` response."""Device.objects.filter(id=device_id).update(push_registration_error_code=error_code)- event = dict(- type="device",- op="update",- device_id=device_id,- push_registration_error_code=error_code,- )+ event = DeviceUpdateEvent(device_id=device_id, push_registration_error_code=error_code)send_event_on_commit(user_profile.realm, event, [user_profile.id])# Report the `REQUEST_EXPIRED_ERROR` to the server admins as it indicates@@ -192,9 +188,7 @@ def handle_register_push_device_to_bouncer(Device.objects.filter(id=device_id).update(push_token_id=token_id_int, pending_push_token_id=None)- event = dict(- type="device",- op="update",+ event = DeviceUpdateEvent(device_id=device_id,push_token_id=token_id_base64,pending_push_token_id=None,