From 364797306956b09ca1f5192d64603741a77fc732 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sun, 10 Jul 2016 18:01:03 -0700 Subject: [PATCH] update_message_backend: Reorganize validation checks. The new organization more clearly does the permission check first. --- zerver/views/messages.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zerver/views/messages.py b/zerver/views/messages.py index 160e9767c2..2716d02bfe 100644 --- a/zerver/views/messages.py +++ b/zerver/views/messages.py @@ -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()