Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
message edit: Handle topic edit tries for private messages.
Abhijeet Prasad Bodas15f78abd68a4
diff --git a/zerver/lib/actions.py b/zerver/lib/actions.pyindex 64029e8b6ae..6e4c7d3bdfe 100644--- a/zerver/lib/actions.py+++ b/zerver/lib/actions.py@@ -2719,6 +2719,8 @@ def validate_message_edit_payload(if not message.is_stream_message():if stream_id is not None:raise JsonableError(_("Private messages cannot be moved to streams."))+ if topic_name is not None:+ raise JsonableError(_("Private messages cannot have topics."))if propagate_mode != "change_one" and topic_name is None and stream_id is None:raise JsonableError(_("Invalid propagate_mode without topic edit"))diff --git a/zerver/tests/test_message_edit.py b/zerver/tests/test_message_edit.pyindex c931e5c7769..78ecc227597 100644--- a/zerver/tests/test_message_edit.py+++ b/zerver/tests/test_message_edit.py@@ -127,6 +127,22 @@ class EditMessagePayloadTest(EditMessageTestCase):self.assert_json_error(result, "Private messages cannot be moved to streams.")+ def test_private_message_edit_topic(self) -> None:+ hamlet = self.example_user("hamlet")+ self.login("hamlet")+ cordelia = self.example_user("cordelia")+ msg_id = self.send_personal_message(hamlet, cordelia)++ result = self.client_patch(+ "/json/messages/" + str(msg_id),+ {+ "message_id": msg_id,+ "topic": "Should not exist",+ },+ )++ self.assert_json_error(result, "Private messages cannot have topics.")+def test_propagate_invalid(self) -> None:self.login("hamlet")id1 = self.send_stream_message(self.example_user("hamlet"), "Scotland", topic_name="topic1")