mirror of https://github.com/zulip/zulip.git
update_message_backend: Reorganize validation checks.
The new organization more clearly does the permission check first.
This commit is contained in:
parent
05632b68e1
commit
3647973069
|
@ -798,10 +798,11 @@ def update_message_backend(request, user_profile,
|
|||
propagate_mode=REQ(default="change_one"),
|
||||
content=REQ(default=None)):
|
||||
# type: (HttpRequest, UserProfile, int, Optional[text_type], Optional[str], Optional[text_type]) -> HttpResponse
|
||||
if subject is None and content is None:
|
||||
return json_error(_("Nothing to change"))
|
||||
if not user_profile.realm.allow_message_editing:
|
||||
return json_error(_("Your organization has turned off message editing."))
|
||||
|
||||
if subject is None and content is None:
|
||||
return json_error(_("Nothing to change"))
|
||||
if subject is not None:
|
||||
subject = subject.strip()
|
||||
if subject == "":
|
||||
|
@ -810,6 +811,7 @@ def update_message_backend(request, user_profile,
|
|||
content = content.strip()
|
||||
if content == "":
|
||||
raise JsonableError(_("Content can't be empty"))
|
||||
|
||||
do_update_message(user_profile, message_id, subject, propagate_mode, content)
|
||||
return json_success()
|
||||
|
||||
|
|
Loading…
Reference in New Issue