mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
message_edit: Disallow resolving empty string topic.
This commit makes changes to the edit message endpoint to disallow resolving empty string topic. It also removes the resolve topic button in the web client from topic popover and message header for empty string topic.
This commit is contained in:
committed by
Tim Abbott
parent
a6ac4ed6bf
commit
fb91cd6f4d
@@ -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 }}
|
||||
|
@@ -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}}
|
||||
|
@@ -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)
|
||||
|
||||
|
@@ -8515,6 +8515,10 @@ paths:
|
||||
the [POST /register](/api/register-queue) response is used for this
|
||||
parameter, 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 string
|
||||
was not a valid topic name for channel messages.
|
||||
|
||||
|
@@ -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")
|
||||
|
Reference in New Issue
Block a user