Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
addressee: Rename "(no topic)" to empty string topic.
Prakhar Pratyush9a461046844d
diff --git a/api_docs/changelog.md b/api_docs/changelog.mdindex fa854dd0ca3..46bde3da375 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 10.0+**Feature level 370**++* [`POST /messages`](/api/send-message),+ [`POST /scheduled_messages`](/api/create-scheduled-message),+ [`PATCH /scheduled_messages/<int:scheduled_message_id>`](/api/update-scheduled-message):+ The `"(no topic)"` value when used for `topic` parameter is+ now interpreted as an empty string.+**Feature level 369*** [`POST /register`](/api/register-queue): Added `navigation_tour_video_url`diff --git a/version.py b/version.pyindex 1aaa69200e5..4b49830ab47 100644--- a/version.py+++ b/version.py@@ -34,7 +34,7 @@ DESKTOP_WARNING_VERSION = "5.9.3"# new level means in api_docs/changelog.md, as well as "**Changes**"# entries in the endpoint's documentation in `zulip.yaml`.-API_FEATURE_LEVEL = 369 # Last bumped for adding `navigation_tour_video_url`.+API_FEATURE_LEVEL = 370 # Last bumped to interpret "(no topic)" as empty string.# 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_send.py b/zerver/actions/message_send.pyindex 2c0e61466e9..b02b545be90 100644--- a/zerver/actions/message_send.py+++ b/zerver/actions/message_send.py@@ -1762,7 +1762,7 @@ def check_message(# else can sneak past the access check.assert sender.bot_type == sender.OUTGOING_WEBHOOK_BOT- if realm.mandatory_topics and topic_name in ("(no topic)", ""):+ if realm.mandatory_topics and topic_name == "":raise JsonableError(_("Topics are required in this organization"))elif addressee.is_private():diff --git a/zerver/lib/addressee.py b/zerver/lib/addressee.pyindex 1924cc56444..ac4b640116c 100644--- a/zerver/lib/addressee.py+++ b/zerver/lib/addressee.py@@ -5,7 +5,10 @@ from django.utils.translation import gettext as _from zerver.lib.exceptions import JsonableErrorfrom zerver.lib.string_validation import check_stream_topic-from zerver.lib.topic import maybe_rename_general_chat_to_empty_topic+from zerver.lib.topic import (+ maybe_rename_general_chat_to_empty_topic,+ maybe_rename_no_topic_to_empty_topic,+)from zerver.models import Realm, Stream, UserProfilefrom zerver.models.users import (get_user_by_id_in_realm_including_cross_realm,@@ -148,6 +151,7 @@ class Addressee:def for_stream(stream: Stream, topic_name: str) -> "Addressee":topic_name = topic_name.strip()topic_name = maybe_rename_general_chat_to_empty_topic(topic_name)+ topic_name = maybe_rename_no_topic_to_empty_topic(topic_name)check_stream_topic(topic_name)return Addressee(msg_type="stream",@@ -159,6 +163,7 @@ class Addressee:def for_stream_name(stream_name: str, topic_name: str) -> "Addressee":topic_name = topic_name.strip()topic_name = maybe_rename_general_chat_to_empty_topic(topic_name)+ topic_name = maybe_rename_no_topic_to_empty_topic(topic_name)check_stream_topic(topic_name)return Addressee(msg_type="stream",@@ -170,6 +175,7 @@ class Addressee:def for_stream_id(stream_id: int, topic_name: str) -> "Addressee":topic_name = topic_name.strip()topic_name = maybe_rename_general_chat_to_empty_topic(topic_name)+ topic_name = maybe_rename_no_topic_to_empty_topic(topic_name)check_stream_topic(topic_name)return Addressee(msg_type="stream",diff --git a/zerver/lib/topic.py b/zerver/lib/topic.pyindex 0cd767681c9..f6442ecc97a 100644--- a/zerver/lib/topic.py+++ b/zerver/lib/topic.py@@ -384,6 +384,12 @@ def maybe_rename_general_chat_to_empty_topic(topic_name: str) -> str:return topic_name+def maybe_rename_no_topic_to_empty_topic(topic_name: str) -> str:+ if topic_name == "(no topic)":+ topic_name = ""+ return topic_name++def maybe_rename_empty_topic_to_general_chat(topic_name: str, is_channel_message: bool, allow_empty_topic_name: bool) -> str:diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yamlindex 953adbdd602..1522a01f165 100644--- a/zerver/openapi/zulip.yaml+++ b/zerver/openapi/zulip.yaml@@ -6640,14 +6640,17 @@ paths:[`POST /register`](/api/register-queue) endpoint to determinethe maximum topic length.- Note: When the value of `realm_empty_topic_display_name` found in- the [POST /register](/api/register-queue) response is used for this+ Note: When `"(no topic)"` or the value of `realm_empty_topic_display_name`+ found in the [POST /register](/api/register-queue) response is used for thisparameter, it is interpreted as an empty string.When [topics are required](/help/require-topics), this parameter can'tbe `"(no topic)"`, an empty string, or the value of `realm_empty_topic_display_name`.- **Changes**: Before Zulip 10.0 (feature level 334), empty string+ **Changes**: Before Zulip 10.0 (feature level 370), `"(no topic)"`+ was not interpreted as an empty string.++ Before Zulip 10.0 (feature level 334), empty stringwas not a valid topic name for channel messages.type: stringexample: Castle@@ -6814,14 +6817,17 @@ paths:[`POST /register`](/api/register-queue) endpoint to determinethe maximum topic length.- Note: When the value of `realm_empty_topic_display_name` found in- the [POST /register](/api/register-queue) response is used for this+ Note: When `"(no topic)"` or the value of `realm_empty_topic_display_name`+ found in the [POST /register](/api/register-queue) response is used for thisparameter, it is interpreted as an empty string.When [topics are required](/help/require-topics), this parameter can'tbe `"(no topic)"`, an empty string, or the value of `realm_empty_topic_display_name`.- **Changes**: Before Zulip 10.0 (feature level 334), empty string+ **Changes**: Before Zulip 10.0 (feature level 370), `"(no topic)"`+ was not interpreted as an empty string.++ Before Zulip 10.0 (feature level 334), empty stringwas not a valid topic name for channel messages.type: stringexample: Castle@@ -7503,14 +7509,17 @@ paths:[`POST /register`](/api/register-queue) endpoint to determinethe maximum topic length.- Note: When the value of `realm_empty_topic_display_name` found in- the [POST /register](/api/register-queue) response is used for this+ Note: When `"(no topic)"` or the value of `realm_empty_topic_display_name`+ found in the [POST /register](/api/register-queue) response is used for thisparameter, it is interpreted as an empty string.When [topics are required](/help/require-topics), this parameter can'tbe `"(no topic)"`, an empty string, or the value of `realm_empty_topic_display_name`.- **Changes**: Before Zulip 10.0 (feature level 334), empty string+ **Changes**: Before Zulip 10.0 (feature level 370), `"(no topic)"`+ was not interpreted as an empty string.++ Before Zulip 10.0 (feature level 334), empty stringwas not a valid topic name for channel messages.New in Zulip 2.0.0. Previous Zulip releases encodeddiff --git a/zerver/webhooks/slack_incoming/tests.py b/zerver/webhooks/slack_incoming/tests.pyindex 0b2ca209683..b0c89854746 100644--- a/zerver/webhooks/slack_incoming/tests.py+++ b/zerver/webhooks/slack_incoming/tests.py@@ -9,7 +9,7 @@ class SlackIncomingHookTests(WebhookTestCase):WEBHOOK_DIR_NAME = "slack_incoming"def test_message(self) -> None:- expected_topic_name = "(no topic)"+ expected_topic_name = ""expected_message = """Hello, world.""".strip()@@ -40,7 +40,7 @@ Hello, world.self.assert_channel_message(message=msg,channel_name=self.CHANNEL_NAME,- topic_name="(no topic)",+ topic_name="",content=output_value,)@@ -89,7 +89,7 @@ Danny Torrence left the following *review* for your property:)def test_message_with_blocks(self) -> None:- expected_topic_name = "(no topic)"+ expected_topic_name = ""expected_message = """Danny Torrence left the following review for your property:@@ -142,7 +142,7 @@ Danny Torrence left the following review for your property:# Paste the JSON into# https://api.slack.com/tools/block-kit-builder to see how it# is rendered in Slack- expected_topic_name = "(no topic)"+ expected_topic_name = ""expected_message = """## Hello from TaskBot@@ -177,7 +177,7 @@ There are two ways to quickly create tasks:def test_attachment_blocks(self) -> None:# On https://api.slack.com/tools/block-kit-builder choose# "Attachment preview" and paste the JSON in.- expected_topic_name = "(no topic)"+ expected_topic_name = ""expected_message = """This is a section block with an accessory image.@@ -199,7 +199,7 @@ This is a section block with a button.)def test_attachment_fields(self) -> None:- expected_topic_name = "(no topic)"+ expected_topic_name = ""expected_message = """Build bla bla succeeded@@ -219,7 +219,7 @@ Value without title)def test_attachment_pieces(self) -> None:- expected_topic_name = "(no topic)"+ expected_topic_name = ""expected_message = """## Test@@ -243,7 +243,7 @@ Value without titlereturn self.webhook_fixture_data("slack_incoming", fixture_name, file_type=file_type)def test_attachment_pieces_title_null(self) -> None:- expected_topic_name = "(no topic)"+ expected_topic_name = ""expected_message = """Sample pretext.@@ -263,7 +263,7 @@ Sample footer.)def test_attachment_pieces_image_url_null(self) -> None:- expected_topic_name = "(no topic)"+ expected_topic_name = ""expected_message = """## [Sample title.](https://www.google.com)@@ -283,7 +283,7 @@ Sample footer.)def test_attachment_pieces_ts_null(self) -> None:- expected_topic_name = "(no topic)"+ expected_topic_name = ""expected_message = """## [Sample title.](https://www.google.com)@@ -303,7 +303,7 @@ Sample footer.)def test_attachment_pieces_text_null(self) -> None:- expected_topic_name = "(no topic)"+ expected_topic_name = ""expected_message = """## [Sample title.](https://www.google.com)@@ -323,7 +323,7 @@ Sample footer.)def test_attachment_pieces_pretext_null(self) -> None:- expected_topic_name = "(no topic)"+ expected_topic_name = ""expected_message = """## [Sample title.](https://www.google.com)@@ -343,7 +343,7 @@ Sample footer.)def test_attachment_pieces_footer_null(self) -> None:- expected_topic_name = "(no topic)"+ expected_topic_name = ""expected_message = """## [Sample title.](https://www.google.com)@@ -363,7 +363,7 @@ Sample text.)def test_attachment_pieces_title_link_null(self) -> None:- expected_topic_name = "(no topic)"+ expected_topic_name = ""expected_message = """## Sample title.