Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
message_edit: Disallow resolving empty string topic.
Prakhar Pratyushfb91cd6f4d01
diff --git a/web/templates/popovers/left_sidebar/left_sidebar_topic_actions_popover.hbs b/web/templates/popovers/left_sidebar/left_sidebar_topic_actions_popover.hbsindex 844c1bb9d72..95344ce04a7 100644--- a/web/templates/popovers/left_sidebar/left_sidebar_topic_actions_popover.hbs+++ b/web/templates/popovers/left_sidebar/left_sidebar_topic_actions_popover.hbs@@ -86,7 +86,7 @@</a></li>{{/if}}- {{#if can_rename_topic}}+ {{#if (and can_rename_topic (not is_empty_string_topic))}}<li role="none" class="link-item popover-menu-list-item"><a role="menuitem" class="sidebar-popover-toggle-resolved popover-menu-link" tabindex="0">{{# if topic_is_resolved }}diff --git a/web/templates/recipient_row.hbs b/web/templates/recipient_row.hbsindex 1c9f34fa234..64047cfbc12 100644--- a/web/templates/recipient_row.hbs+++ b/web/templates/recipient_row.hbs@@ -54,7 +54,7 @@<i class="fa fa-pencil on_hover_topic_edit recipient_bar_icon hidden-for-spectators" data-tippy-content="{{t 'Edit topic'}}" role="button" tabindex="0" aria-label="{{t 'Edit topic' }}"></i>{{/if}}- {{#if user_can_resolve_topic}}+ {{#if (and user_can_resolve_topic (not is_empty_string_topic))}}{{#if topic_is_resolved}}<i class="fa fa-check on_hover_topic_unresolve recipient_bar_icon hidden-for-spectators" data-topic-name="{{topic}}" data-tippy-content="{{t 'Mark as unresolved' }}" role="button" tabindex="0" aria-label="{{t 'Mark as unresolved' }}"></i>{{else}}diff --git a/zerver/actions/message_edit.py b/zerver/actions/message_edit.pyindex 8b87b54a471..fd2861920e2 100644--- a/zerver/actions/message_edit.py+++ b/zerver/actions/message_edit.py@@ -121,6 +121,12 @@ def validate_message_edit_payload(if propagate_mode != "change_one" and topic_name is None and stream_id is None:raise JsonableError(_("Invalid propagate_mode without topic edit"))+ if topic_name in {+ RESOLVED_TOPIC_PREFIX.strip(),+ f"{RESOLVED_TOPIC_PREFIX}{Message.EMPTY_TOPIC_FALLBACK_NAME}",+ }:+ raise JsonableError(_("General chat cannot be marked as resolved"))+if topic_name is not None:check_stream_topic(topic_name)diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yamlindex 9a709ac2caf..48d5f1c1b59 100644--- a/zerver/openapi/zulip.yaml+++ b/zerver/openapi/zulip.yaml@@ -8515,6 +8515,10 @@ paths:the [POST /register](/api/register-queue) response is used for thisparameter, it is interpreted as an empty string.+ You can [resolve topics](/help/resolve-a-topic) by editing the topic to+ `✔ {original_topic}` with the `propagate_mode` parameter set to+ `"change_all"`. The empty string topic cannot be marked as resolved.+**Changes**: Before Zulip 10.0 (feature level 334), empty stringwas not a valid topic name for channel messages.diff --git a/zerver/tests/test_message_move_topic.py b/zerver/tests/test_message_move_topic.pyindex 16e20768a6b..fcdeefabb09 100644--- a/zerver/tests/test_message_move_topic.py+++ b/zerver/tests/test_message_move_topic.py@@ -1757,3 +1757,17 @@ class MessageMoveTopicTest(ZulipTestCase):topic_messages[0].content,f"@_**Iago|{admin_user.id}** has marked this topic as resolved.",)++ def test_resolve_empty_string_topic(self) -> None:+ hamlet = self.example_user("hamlet")++ message_id = self.send_stream_message(hamlet, "Denmark", topic_name="")+ result = self.resolve_topic_containing_message(hamlet, target_message_id=message_id)+ self.assert_json_error(result, "General chat cannot be marked as resolved")++ # Verification for old clients that don't support empty string topic.+ message_id = self.send_stream_message(+ hamlet, "Denmark", topic_name=Message.EMPTY_TOPIC_FALLBACK_NAME+ )+ result = self.resolve_topic_containing_message(hamlet, target_message_id=message_id)+ self.assert_json_error(result, "General chat cannot be marked as resolved")