mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 17:07:07 +00:00
message edit: Handle topic edit tries for private messages.
Fixes #18604.
This commit is contained in:
committed by
Tim Abbott
parent
4b30fc01e4
commit
15f78abd68
@@ -2719,6 +2719,8 @@ def validate_message_edit_payload(
|
|||||||
if not message.is_stream_message():
|
if not message.is_stream_message():
|
||||||
if stream_id is not None:
|
if stream_id is not None:
|
||||||
raise JsonableError(_("Private messages cannot be moved to streams."))
|
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:
|
if propagate_mode != "change_one" and topic_name is None and stream_id is None:
|
||||||
raise JsonableError(_("Invalid propagate_mode without topic edit"))
|
raise JsonableError(_("Invalid propagate_mode without topic edit"))
|
||||||
|
|||||||
@@ -127,6 +127,22 @@ class EditMessagePayloadTest(EditMessageTestCase):
|
|||||||
|
|
||||||
self.assert_json_error(result, "Private messages cannot be moved to streams.")
|
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:
|
def test_propagate_invalid(self) -> None:
|
||||||
self.login("hamlet")
|
self.login("hamlet")
|
||||||
id1 = self.send_stream_message(self.example_user("hamlet"), "Scotland", topic_name="topic1")
|
id1 = self.send_stream_message(self.example_user("hamlet"), "Scotland", topic_name="topic1")
|
||||||
|
|||||||
Reference in New Issue
Block a user