Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
message_edit: Don't treat "stream_id=message's current channel" as move.
Prakhar Pratyushea5ea39c2c48
diff --git a/api_docs/changelog.md b/api_docs/changelog.mdindex f4919fdd2bd..2eb2335341e 100644--- a/api_docs/changelog.md+++ b/api_docs/changelog.md@@ -20,6 +20,14 @@ format used by the Zulip server that they are interacting with.## Changes in Zulip 13.0+**Feature level 509**++**Feature level ZF-25c66e**++* [`PATCH /messages/{message_id}`](/api/update-message): Fixed a bug where+ passing the `stream_id` that the message is already in was processed as+ a channel move.+**Feature level 508*** [`POST /messages`](/api/send-message): Added `message_url` anddiff --git a/version.py b/version.pyindex 3c378e6209b..8c1545efe8f 100644--- a/version.py+++ b/version.py@@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.9.3"# https://zulip.readthedocs.io/en/latest/documentation/api.html#step-by-step-guide# Also available at docs/documentation/api.md.-API_FEATURE_LEVEL = 508+API_FEATURE_LEVEL = 509# Bump the minor PROVISION_VERSION to indicate that folks should provision# only when going from an old version of the code to a newer version. Bumpdiff --git a/zerver/actions/message_edit.py b/zerver/actions/message_edit.pyindex 3e5e11a5c00..584af03b59c 100644--- a/zerver/actions/message_edit.py+++ b/zerver/actions/message_edit.py@@ -1686,6 +1686,13 @@ def check_update_message(if topic_name == message.topic_name():topic_name = None+ if (+ stream_id is not None+ and message.is_channel_message+ and stream_id == message.recipient.type_id+ ):+ stream_id = None+validate_message_edit_payload(message, stream_id, topic_name, propagate_mode, content, prev_content_sha256)diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yamlindex 79a37f294c1..9510b5d32a2 100644--- a/zerver/openapi/zulip.yaml+++ b/zerver/openapi/zulip.yaml@@ -10704,6 +10704,10 @@ paths:same time, so sending both `content` and `stream_id` parameters willthrow an error.+ **Changes**: In Zulip 13.0 (feature level 509), fixed a bug where+ passing the channel ID that the message is already in was processed as+ a channel move.+**Changes**: New in Zulip 3.0 (feature level 1).type: integerexample: 43diff --git a/zerver/tests/test_message_move_stream.py b/zerver/tests/test_message_move_stream.pyindex e4e59af98ea..7dbaff66d91 100644--- a/zerver/tests/test_message_move_stream.py+++ b/zerver/tests/test_message_move_stream.py@@ -26,6 +26,7 @@ from zerver.lib.topic import RESOLVED_TOPIC_PREFIXfrom zerver.lib.types import UserGroupMembersDatafrom zerver.lib.url_encoding import stream_message_urlfrom zerver.lib.user_groups import UserGroupMembershipDetails+from zerver.lib.utils import assert_is_not_nonefrom zerver.models import Message, NamedUserGroup, Stream, UserMessage, UserProfilefrom zerver.models.groups import SystemGroupsfrom zerver.models.realms import get_realm@@ -158,6 +159,34 @@ class MessageMoveStreamTest(ZulipTestCase):messages = get_topic_messages(user_profile, new_stream, "test")self.assert_length(messages, 0)+ def test_move_message_to_same_channel_is_not_a_move(self) -> None:+ user_profile = self.example_user("hamlet")+ self.login_user(user_profile)+ channel = get_stream("Denmark", user_profile.realm)++ # Request moving message to the channel it's already in.+ msg_id = self.send_stream_message(user_profile, channel.name, topic_name="topic1")+ result = self.client_patch(+ "/json/messages/" + str(msg_id),+ {"stream_id": channel.id},+ )+ self.assert_json_error(result, "Nothing to change")++ # Alongside a topic change, it is a plain topic edit; the edit+ # history must not claim the channel changed.+ result = self.client_patch(+ "/json/messages/" + str(msg_id),+ {"stream_id": channel.id, "topic": "topic2", "propagate_mode": "change_all"},+ )+ self.assert_json_success(result)+ [edit_history_entry] = orjson.loads(+ assert_is_not_none(Message.objects.get(id=msg_id).edit_history)+ )+ self.assertEqual(edit_history_entry["prev_topic"], "topic1")+ self.assertEqual(edit_history_entry["topic"], "topic2")+ self.assertNotIn("prev_stream", edit_history_entry)+ self.assertNotIn("stream", edit_history_entry)+def test_change_all_propagate_mode_for_moving_old_messages(self) -> None:user_profile = self.example_user("hamlet")realm = user_profile.realm