Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

message_edit: Reject buggy noop topic edit requests.

Tim Abbottb2dd15fd863e
diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py
index fed1e2073fd..c29b1637685 100644
--- a/zerver/lib/actions.py
+++ b/zerver/lib/actions.py
@@ -2852,6 +2852,9 @@ def check_update_message(
# use REQ_topic as well (or otherwise are guaranteed to strip input).
if topic_name is not None:
topic_name = topic_name.strip()
+ if topic_name == message.topic_name():
+ topic_name = None
+
validate_message_edit_payload(message, stream_id, topic_name, propagate_mode, content)
is_no_topic_msg = message.topic_name() == "(no topic)"
diff --git a/zerver/tests/test_message_edit.py b/zerver/tests/test_message_edit.py
index 326def25c40..268c378631b 100644
--- a/zerver/tests/test_message_edit.py
+++ b/zerver/tests/test_message_edit.py
@@ -1968,6 +1968,18 @@ class EditMessageTest(EditMessageTestCase):
)
id2 = self.send_stream_message(admin_user, "new", topic_name=original_topic)
+ # Check that we don't incorrectly send "unresolve topic"
+ # notifications when asking the preserve the current topic.
+ result = self.client_patch(
+ "/json/messages/" + str(id1),
+ {
+ "message_id": id1,
+ "topic": original_topic,
+ "propagate_mode": "change_all",
+ },
+ )
+ self.assert_json_error(result, "Nothing to change")
+
resolved_topic = RESOLVED_TOPIC_PREFIX + original_topic
result = self.client_patch(
"/json/messages/" + str(id1),