mirror of https://github.com/zulip/zulip.git
typing: Move to parameter validation to view code.
This commit is contained in:
parent
2a8e9db8f1
commit
08116a17b0
|
@ -2234,10 +2234,7 @@ def do_send_typing_notification(
|
|||
# check_send_typing_notification:
|
||||
# Checks the typing notification and sends it
|
||||
def check_send_typing_notification(sender: UserProfile, user_ids: List[int], operator: str) -> None:
|
||||
|
||||
realm = sender.realm
|
||||
if len(user_ids) == 0:
|
||||
raise JsonableError(_("Missing parameter: 'to' (recipient)"))
|
||||
|
||||
if sender.id not in user_ids:
|
||||
user_ids.append(sender.id)
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
from typing import List
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.decorator import REQ, has_request_variables
|
||||
from zerver.lib.actions import check_send_typing_notification
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.lib.validator import check_int, check_list, check_string_in
|
||||
from zerver.models import UserProfile
|
||||
|
||||
|
@ -16,7 +17,10 @@ def send_notification_backend(
|
|||
request: HttpRequest,
|
||||
user_profile: UserProfile,
|
||||
operator: str = REQ("op", str_validator=check_string_in(VALID_OPERATOR_TYPES)),
|
||||
notification_to: List[int] = REQ("to", validator=check_list(check_int)),
|
||||
user_ids: List[int] = REQ("to", validator=check_list(check_int)),
|
||||
) -> HttpResponse:
|
||||
check_send_typing_notification(user_profile, notification_to, operator)
|
||||
if len(user_ids) == 0:
|
||||
return json_error(_("Missing parameter: 'to' (recipient)"))
|
||||
|
||||
check_send_typing_notification(user_profile, user_ids, operator)
|
||||
return json_success()
|
||||
|
|
Loading…
Reference in New Issue