mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 12:33:40 +00:00
push_notifications: Fix mypy annotation logic around push tokens.
I'm not 100% confident this is long-term correct, but at least it's consistent.
This commit is contained in:
@@ -24,7 +24,7 @@ def validate_entity(entity):
|
||||
raise JsonableError(_("Must validate with valid Zulip server API key"))
|
||||
|
||||
def validate_bouncer_token_request(entity, token, kind):
|
||||
# type: (Union[UserProfile, RemoteZulipServer], str, int) -> None
|
||||
# type: (Union[UserProfile, RemoteZulipServer], bytes, int) -> None
|
||||
if kind not in [RemotePushDeviceToken.APNS, RemotePushDeviceToken.GCM]:
|
||||
raise JsonableError(_("Invalid token type"))
|
||||
validate_entity(entity)
|
||||
@@ -38,7 +38,7 @@ def report_error(request, deployment, type=REQ(), report=REQ(validator=check_dic
|
||||
@has_request_variables
|
||||
def remote_server_register_push(request, entity, user_id=REQ(),
|
||||
token=REQ(), token_kind=REQ(validator=check_int), ios_app_id=None):
|
||||
# type: (HttpRequest, Union[UserProfile, RemoteZulipServer], int, str, int, Optional[Text]) -> HttpResponse
|
||||
# type: (HttpRequest, Union[UserProfile, RemoteZulipServer], int, bytes, int, Optional[Text]) -> HttpResponse
|
||||
validate_bouncer_token_request(entity, token, token_kind)
|
||||
server = cast(RemoteZulipServer, entity)
|
||||
|
||||
@@ -63,7 +63,7 @@ def remote_server_register_push(request, entity, user_id=REQ(),
|
||||
@has_request_variables
|
||||
def remote_server_unregister_push(request, entity, token=REQ(),
|
||||
token_kind=REQ(validator=check_int), ios_app_id=None):
|
||||
# type: (HttpRequest, Union[UserProfile, RemoteZulipServer], str, int, Optional[Text]) -> HttpResponse
|
||||
# type: (HttpRequest, Union[UserProfile, RemoteZulipServer], bytes, int, Optional[Text]) -> HttpResponse
|
||||
validate_bouncer_token_request(entity, token, token_kind)
|
||||
server = cast(RemoteZulipServer, entity)
|
||||
deleted = RemotePushDeviceToken.objects.filter(token=token,
|
||||
|
Reference in New Issue
Block a user