zilencer: Add endpoint to register push device to bouncer.

This commit adds a zilencer endpoint to let self-hosted
servers register push devices to whom mobile push notifications
will be sent.

POST "/api/v1/remotes/push/e2ee/register"
Payload: realm_uuid, push_account_id, encrypted_push_registration,
bouncer_public_key

The post request needs to be authenticated with the server’s API key.

Note: For Zulip Cloud, a background fact about the push bouncer is
that it runs on the same server and database as the main application;
it’s not a separate service.
So, as an optimization, we plan to directly call the
`do_register_remote_push_device` function and skip the HTTP request.
This commit is contained in:
Prakhar Pratyush
2025-06-10 22:52:32 +05:30
committed by Tim Abbott
parent 5facec1cc3
commit 3c6a3b0d77
6 changed files with 377 additions and 3 deletions

View File

@@ -59,6 +59,8 @@ class ErrorCode(Enum):
CANNOT_ADMINISTER_CHANNEL = auto()
REMOTE_SERVER_VERIFICATION_SECRET_NOT_PREPARED = auto()
HOSTNAME_ALREADY_IN_USE_BOUNCER_ERROR = auto()
INVALID_BOUNCER_PUBLIC_KEY = auto()
REQUEST_EXPIRED = auto()
class JsonableError(Exception):
@@ -827,3 +829,37 @@ class SlackImportInvalidFileError(Exception):
def __init__(self, message: str) -> None:
super().__init__(message)
self.message = message
class InvalidBouncerPublicKeyError(JsonableError):
code = ErrorCode.INVALID_BOUNCER_PUBLIC_KEY
def __init__(self) -> None:
pass
@staticmethod
@override
def msg_format() -> str:
return _("Invalid bouncer_public_key")
class RequestExpiredError(JsonableError):
code = ErrorCode.REQUEST_EXPIRED
def __init__(self) -> None:
pass
@staticmethod
@override
def msg_format() -> str:
return _("Request expired")
class InvalidEncryptedPushRegistrationError(JsonableError):
def __init__(self) -> None:
pass
@staticmethod
@override
def msg_format() -> str:
return _("Invalid encrypted_push_registration")