mirror of https://github.com/zulip/zulip.git
Use check_list instead of json_to_list.
(imported from commit 9ead12bc2a4744b94a747ca27054124aacde7ae4)
This commit is contained in:
parent
8b58d8574b
commit
3d04f5f738
|
@ -49,11 +49,12 @@ def check_list(sub_validator, length=None):
|
|||
if length is not None and length != len(val):
|
||||
return '%s should have exactly %d items' % (var_name, length)
|
||||
|
||||
for i, item in enumerate(val):
|
||||
vname = '%s[%d]' % (var_name, i)
|
||||
error = sub_validator(vname, item)
|
||||
if error:
|
||||
return error
|
||||
if sub_validator:
|
||||
for i, item in enumerate(val):
|
||||
vname = '%s[%d]' % (var_name, i)
|
||||
error = sub_validator(vname, item)
|
||||
if error:
|
||||
return error
|
||||
|
||||
return None
|
||||
return f
|
||||
|
|
|
@ -5,10 +5,10 @@ from zerver.models import get_client
|
|||
|
||||
from zerver.decorator import asynchronous, \
|
||||
authenticated_json_post_view, internal_notify_view, RespondAsynchronously, \
|
||||
has_request_variables, json_to_list, json_to_dict, REQ
|
||||
has_request_variables, json_to_dict, REQ
|
||||
|
||||
from zerver.lib.response import json_success, json_error
|
||||
from zerver.lib.validator import check_bool
|
||||
from zerver.lib.validator import check_bool, check_list, check_string
|
||||
from zerver.tornado_callbacks import process_notification
|
||||
|
||||
from zerver.lib.event_queue import allocate_client_descriptor, get_client_descriptor
|
||||
|
@ -48,9 +48,9 @@ def get_events_backend(request, user_profile, handler = None,
|
|||
queue_id = REQ(default=None),
|
||||
apply_markdown = REQ(default=False, validator=check_bool),
|
||||
all_public_streams = REQ(default=False, validator=check_bool),
|
||||
event_types = REQ(default=None, converter=json_to_list),
|
||||
event_types = REQ(default=None, validator=check_list(check_string)),
|
||||
dont_block = REQ(default=False, validator=check_bool),
|
||||
narrow = REQ(default=[], converter=json_to_list),
|
||||
narrow = REQ(default=[], validator=check_list(None)),
|
||||
lifespan_secs = REQ(default=0, converter=int)):
|
||||
if user_client is None:
|
||||
user_client = request.client
|
||||
|
|
|
@ -55,7 +55,7 @@ from zerver.lib.validator import check_string, check_list, check_dict, check_int
|
|||
from zerver.decorator import require_post, \
|
||||
authenticated_api_view, authenticated_json_post_view, \
|
||||
has_request_variables, authenticated_json_view, \
|
||||
to_non_negative_int, json_to_dict, json_to_list, json_to_bool, \
|
||||
to_non_negative_int, json_to_dict, json_to_bool, \
|
||||
JsonableError, get_user_profile_by_email, REQ, require_realm_admin, \
|
||||
RequestVariableConversionError
|
||||
from zerver.lib.avatar import avatar_url, get_avatar_url
|
||||
|
|
Loading…
Reference in New Issue