Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

api: Improve encoding of stream/topic max field lengths.

Tim Abbott4a3ad0da06b3
diff --git a/static/js/subs.js b/static/js/subs.js
index 374441be15d..bfc732c3af2 100644
--- a/static/js/subs.js
+++ b/static/js/subs.js
@@ -627,8 +627,8 @@ export function setup_page(callback) {
const template_data = {
can_create_streams: page_params.can_create_streams,
hide_all_streams: !should_list_all_streams(),
- max_name_length: page_params.stream_name_max_length,
- max_description_length: page_params.stream_description_max_length,
+ max_name_length: page_params.max_stream_name_length,
+ max_description_length: page_params.max_stream_description_length,
is_owner: page_params.is_owner,
stream_privacy_policy_values: stream_data.stream_privacy_policy_values,
stream_post_policy_values: stream_data.stream_post_policy_values,
diff --git a/templates/zerver/api/changelog.md b/templates/zerver/api/changelog.md
index 358a0cab0e2..3451fd304f0 100644
--- a/templates/zerver/api/changelog.md
+++ b/templates/zerver/api/changelog.md
@@ -10,6 +10,13 @@ below features are supported.
## Changes in Zulip 4.0
+**Feature level 53**
+
+* [`POST /register`](/api/register-queue): Added `max_topic_length`
+ and renamed `max_stream_name_length` and
+ `max_stream_description_length` to allow clients to transparently
+ support these values changing in a future server version.
+
**Feature level 52**
* `PATCH /realm`: Removed unnecessary JSON-encoding of string
diff --git a/version.py b/version.py
index e0d7adf7e55..a94337fff24 100644
--- a/version.py
+++ b/version.py
@@ -30,7 +30,7 @@ DESKTOP_WARNING_VERSION = "5.2.0"
#
# Changes should be accompanied by documentation explaining what the
# new level means in templates/zerver/api/changelog.md.
-API_FEATURE_LEVEL = 52
+API_FEATURE_LEVEL = 53
# 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. Bump
diff --git a/zerver/lib/events.py b/zerver/lib/events.py
index e87eba74e6a..1c64fdcfcdd 100644
--- a/zerver/lib/events.py
+++ b/zerver/lib/events.py
@@ -49,6 +49,7 @@ from zerver.lib.user_mutes import get_user_mutes
from zerver.lib.user_status import get_user_info_dict
from zerver.lib.users import get_cross_realm_dicts, get_raw_user_data, is_administrator_role
from zerver.models import (
+ MAX_TOPIC_NAME_LENGTH,
Client,
CustomProfileField,
Message,
@@ -250,6 +251,10 @@ def fetch_initial_state_data(
else:
state["realm_signup_notifications_stream_id"] = -1
+ state["max_stream_name_length"] = Stream.MAX_NAME_LENGTH
+ state["max_stream_description_length"] = Stream.MAX_DESCRIPTION_LENGTH
+ state["max_topic_length"] = MAX_TOPIC_NAME_LENGTH
+
if want("realm_domains"):
state["realm_domains"] = get_realm_domains(realm)
@@ -415,8 +420,6 @@ def fetch_initial_state_data(
# be used when the mobile apps support logged-out
# access.
state["streams"] = get_web_public_streams(realm) # nocoverage
- state["stream_name_max_length"] = Stream.MAX_NAME_LENGTH
- state["stream_description_max_length"] = Stream.MAX_DESCRIPTION_LENGTH
if want("default_streams"):
if settings_user.is_guest:
# Guest users and logged-out users don't have access to
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index 7beb2cbf757..97bae97f594 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -6885,6 +6885,41 @@ paths:
**Deprecated**: This field may be removed in future versions as it no
longer has a clear purpose. Clients wishing to fetch the latest messages
should pass `anchor="latest"` to `GET /messages`.
+ max_stream_name_length:
+ type: integer
+ description: |
+ Present if `realm` is present in `fetch_event_types`.
+
+ The maximum allowed length for a stream name. Clients should use
+ these properties rather than hardcoding field sizes, as they may
+ change in a future Zulip release.
+
+ **Changes**: New in Zulip 4.0 (feature level 53). Previously,
+ this required `stream` in `fetch_event_types`, was called
+ `stream_name_max_length`, and always had value 60.
+ max_stream_description_length:
+ type: integer
+ description: |
+ Present if `realm` is present in `fetch_event_types`.
+
+ The maximum allowed length for a stream description. Clients should use
+ these properties rather than hardcoding field sizes, as they may
+ change in a future Zulip release.
+
+ **Changes**: New in Zulip 4.0 (feature level 53). Previously,
+ this required `stream` in `fetch_event_types`, was called
+ `stream_description_max_length`, and always had value 1024.
+ max_topic_length:
+ type: integer
+ description: |
+ Present if `realm` is present in `fetch_event_types`.
+
+ The maximum allowed length for a topic. Clients should use
+ these properties rather than hardcoding field sizes, as they may
+ change in a future Zulip release.
+
+ **Changes**: New in Zulip 4.0 (feature level 53). Previously,
+ this always had value 60.
muted_topics:
type: array
description: |
@@ -7303,22 +7338,6 @@ paths:
For organization administrators, this will include all private streams
in the organization.
- stream_name_max_length:
- type: integer
- description: |
- Present if `stream` is present in `fetch_event_types`.
-
- The maximum allowed length for a stream name. Clients should use
- these properties rather than hardcoding field sizes, as they may
- change in a future Zulip release.
- stream_description_max_length:
- type: integer
- description: |
- Present if `stream` is present in `fetch_event_types`.
-
- The maximum allowed length for a stream description. Clients should use
- these properties rather than hardcoding field sizes, as they may
- change in a future Zulip release.
realm_default_streams:
type: array
items:
diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py
index 36cbb859017..b5b4b29d2cd 100644
--- a/zerver/tests/test_home.py
+++ b/zerver/tests/test_home.py
@@ -106,6 +106,9 @@ class HomeTest(ZulipTestCase):
"max_icon_file_size",
"max_logo_file_size",
"max_message_id",
+ "max_stream_description_length",
+ "max_stream_name_length",
+ "max_topic_length",
"message_content_in_email_notifications",
"muted_topics",
"muted_users",
@@ -206,8 +209,6 @@ class HomeTest(ZulipTestCase):
"starred_message_counts",
"starred_messages",
"stop_words",
- "stream_description_max_length",
- "stream_name_max_length",
"subscriptions",
"test_suite",
"timezone",