mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 20:44:04 +00:00
validator: Replace converter=int with json_validator=check_int.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
6c6aa0cb37
commit
c3788ab847
@@ -130,7 +130,8 @@ class DecoratorTestCase(ZulipTestCase):
|
||||
def test_REQ_aliases(self) -> None:
|
||||
@has_request_variables
|
||||
def double(
|
||||
request: HttpRequest, x: int = REQ(whence="number", aliases=["x", "n"], converter=int)
|
||||
request: HttpRequest,
|
||||
x: int = REQ(whence="number", aliases=["x", "n"], json_validator=check_int),
|
||||
) -> HttpResponse:
|
||||
return json_response(data={"number": x + x})
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ def get_events_backend(
|
||||
user_client: Optional[Client] = REQ(
|
||||
converter=get_client, default=None, intentionally_undocumented=True
|
||||
),
|
||||
last_event_id: Optional[int] = REQ(converter=int, default=None),
|
||||
last_event_id: Optional[int] = REQ(json_validator=check_int, default=None),
|
||||
queue_id: Optional[str] = REQ(default=None),
|
||||
# apply_markdown, client_gravatar, all_public_streams, and various
|
||||
# other parameters are only used when registering a new queue via this
|
||||
|
||||
@@ -7,7 +7,7 @@ from zerver.lib.events import do_events_register
|
||||
from zerver.lib.exceptions import JsonableError
|
||||
from zerver.lib.request import REQ, RequestNotes, has_request_variables
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.validator import check_bool, check_dict, check_list, check_string
|
||||
from zerver.lib.validator import check_bool, check_dict, check_int, check_list, check_string
|
||||
from zerver.models import Stream, UserProfile
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ def events_register_backend(
|
||||
narrow: NarrowT = REQ(
|
||||
json_validator=check_list(check_list(check_string, length=2)), default=[]
|
||||
),
|
||||
queue_lifespan_secs: int = REQ(converter=int, default=0, documentation_pending=True),
|
||||
queue_lifespan_secs: int = REQ(json_validator=check_int, default=0, documentation_pending=True),
|
||||
) -> HttpResponse:
|
||||
if all_public_streams and not user_profile.can_access_public_streams():
|
||||
raise JsonableError(_("User not authorized for this query"))
|
||||
|
||||
Reference in New Issue
Block a user