zerver: Add endpoint to register a push device to server.

This commit adds an endpoint to register a push device
to receive E2EE push notifications.
This commit is contained in:
Prakhar Pratyush
2025-06-02 22:03:06 +05:30
committed by Tim Abbott
parent c846302417
commit 5f8edf669d
17 changed files with 711 additions and 11 deletions

View File

@@ -21,9 +21,11 @@ from zerver.actions.realm_settings import (
)
from zerver.lib import redis_utils
from zerver.lib.exceptions import (
InvalidBouncerPublicKeyError,
JsonableError,
MissingRemoteRealmError,
RemoteRealmServerMismatchError,
RequestExpiredError,
)
from zerver.lib.outgoing_http import OutgoingSession
from zerver.lib.queue import queue_event_on_commit
@@ -217,6 +219,12 @@ def send_to_push_bouncer(
# The callers requesting this endpoint want the exception to propagate
# so they can catch it.
raise RemoteRealmServerMismatchError
elif endpoint == "push/e2ee/register" and code == "INVALID_BOUNCER_PUBLIC_KEY":
raise InvalidBouncerPublicKeyError
elif endpoint == "push/e2ee/register" and code == "REQUEST_EXPIRED":
raise RequestExpiredError
elif endpoint == "push/e2ee/register" and code == "MISSING_REMOTE_REALM":
raise MissingRemoteRealmError
else:
# But most other errors coming from the push bouncer
# server are client errors (e.g. never-registered token)