mirror of
https://github.com/zulip/zulip.git
synced 2025-10-24 08:33:43 +00:00
register_push_device: Add an error code to push-not-configured error.
This commit adds an error code to make it easier for clients to identify when push device registration is rejected due to server not being configured to use push notification service. Fixes part of 35368.
This commit is contained in:
committed by
Tim Abbott
parent
a4d70505ec
commit
1c7dd83dbe
@@ -61,6 +61,7 @@ class ErrorCode(Enum):
|
||||
HOSTNAME_ALREADY_IN_USE_BOUNCER_ERROR = auto()
|
||||
INVALID_BOUNCER_PUBLIC_KEY = auto()
|
||||
REQUEST_EXPIRED = auto()
|
||||
PUSH_SERVICE_NOT_CONFIGURED = auto()
|
||||
|
||||
|
||||
class JsonableError(Exception):
|
||||
@@ -863,3 +864,15 @@ class InvalidEncryptedPushRegistrationError(JsonableError):
|
||||
@override
|
||||
def msg_format() -> str:
|
||||
return _("Invalid encrypted_push_registration")
|
||||
|
||||
|
||||
class PushServiceNotConfiguredError(JsonableError):
|
||||
code = ErrorCode.PUSH_SERVICE_NOT_CONFIGURED
|
||||
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
@override
|
||||
def msg_format() -> str:
|
||||
return _("Server is not configured to use push notification service.")
|
||||
|
||||
@@ -12619,7 +12619,7 @@ paths:
|
||||
{
|
||||
"result": "error",
|
||||
"msg": "Server is not configured to use push notification service.",
|
||||
"code": "BAD_REQUEST",
|
||||
"code": "PUSH_SERVICE_NOT_CONFIGURED",
|
||||
}
|
||||
description: |
|
||||
Error when the server is not configured to use push notification service:
|
||||
|
||||
@@ -15,6 +15,7 @@ from zerver.lib.exceptions import (
|
||||
JsonableError,
|
||||
MissingRemoteRealmError,
|
||||
OrganizationOwnerRequiredError,
|
||||
PushServiceNotConfiguredError,
|
||||
RemoteRealmServerMismatchError,
|
||||
ResourceNotFoundError,
|
||||
)
|
||||
@@ -280,7 +281,7 @@ def register_push_device(
|
||||
encrypted_push_registration: str,
|
||||
) -> HttpResponse:
|
||||
if not (settings.ZILENCER_ENABLED or uses_notification_bouncer()):
|
||||
raise JsonableError(_("Server is not configured to use push notification service."))
|
||||
raise PushServiceNotConfiguredError
|
||||
|
||||
# Idempotency
|
||||
already_registered = PushDevice.objects.filter(
|
||||
|
||||
Reference in New Issue
Block a user