mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
zilencer: Improve json error when plan doesn't allow push notifs.
This allows the self-hosted server to explicitly test for that exception and catch and log it nicely.
This commit is contained in:
committed by
Tim Abbott
parent
d29cd04387
commit
3bda31c48c
@@ -472,6 +472,16 @@ class OldZulipServerError(JsonableError):
|
||||
self._msg: str = msg
|
||||
|
||||
|
||||
class PushNotificationsDisallowedError(JsonableError):
|
||||
code = ErrorCode.PUSH_NOTIFICATIONS_DISALLOWED
|
||||
|
||||
def __init__(self, reason: str) -> None:
|
||||
msg = _(
|
||||
"Your plan doesn't allow sending push notifications. Reason provided by the server: {reason}"
|
||||
).format(reason=reason)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
@has_request_variables
|
||||
def remote_server_notify_push(
|
||||
request: HttpRequest,
|
||||
@@ -502,7 +512,8 @@ def remote_server_notify_push(
|
||||
if server.last_api_feature_level is None:
|
||||
raise OldZulipServerError(_("Your plan doesn't allow sending push notifications."))
|
||||
else:
|
||||
raise JsonableError(_("Your plan doesn't allow sending push notifications."))
|
||||
reason = push_status.message
|
||||
raise PushNotificationsDisallowedError(reason=reason)
|
||||
|
||||
android_devices = list(
|
||||
RemotePushDeviceToken.objects.filter(
|
||||
|
||||
Reference in New Issue
Block a user