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.

register: Pass channel folder max name and description length.

Sahil Batradb00ceaeb2bd
diff --git a/api_docs/changelog.md b/api_docs/changelog.md
index ff9a80689be..82830b49e98 100644
--- a/api_docs/changelog.md
+++ b/api_docs/changelog.md
@@ -20,6 +20,12 @@ format used by the Zulip server that they are interacting with.
## Changes in Zulip 11.0
+**Feature level 410**
+
+* [`POST /register`](/api/register-queue): Added
+ `max_channel_folder_name_length` and
+ `max_channel_folder_description_length` fields to the response.
+
**Feature level 409**
* `PATCH /realm`, [`POST /register`](/api/register-queue),
diff --git a/version.py b/version.py
index e3846a3614a..30a7b2a4ba7 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 = 409
+API_FEATURE_LEVEL = 410
# 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/web/src/channel_folders.ts b/web/src/channel_folders.ts
index 4f5a2296b20..34c7a9bc8ee 100644
--- a/web/src/channel_folders.ts
+++ b/web/src/channel_folders.ts
@@ -10,9 +10,6 @@ export type ChannelFolder = z.infer<typeof channel_folder_schema>;
let channel_folder_name_dict: FoldDict<ChannelFolder>;
let channel_folder_by_id_dict: Map<number, ChannelFolder>;
-export const MAX_CHANNEL_FOLDER_NAME_LENGTH = 100;
-export const MAX_CHANNEL_FOLDER_DESCRIPTION_LENGTH = 1024;
-
export function add(channel_folder: ChannelFolder): void {
channel_folder_name_dict.set(channel_folder.name, channel_folder);
channel_folder_by_id_dict.set(channel_folder.id, channel_folder);
diff --git a/web/src/state_data.ts b/web/src/state_data.ts
index 5d77fa54313..783c6d1c34c 100644
--- a/web/src/state_data.ts
+++ b/web/src/state_data.ts
@@ -287,6 +287,8 @@ export const realm_schema = z.object({
z.object({disabled: z.object({id: z.number(), name: z.string()})}),
),
max_avatar_file_size_mib: z.number(),
+ max_channel_folder_description_length: z.number(),
+ max_channel_folder_name_length: z.number(),
max_file_upload_size_mib: z.number(),
max_icon_file_size_mib: z.number(),
max_logo_file_size_mib: z.number(),
diff --git a/web/src/stream_edit.ts b/web/src/stream_edit.ts
index 32cf4fe67cc..ead44e13dc9 100644
--- a/web/src/stream_edit.ts
+++ b/web/src/stream_edit.ts
@@ -915,9 +915,8 @@ export function initialize(): void {
$("#channels_overlay_container").on("click", ".create-channel-folder-button", () => {
const html_body = render_create_channel_folder_modal({
- max_channel_folder_name_length: channel_folders.MAX_CHANNEL_FOLDER_NAME_LENGTH,
- max_channel_folder_description_length:
- channel_folders.MAX_CHANNEL_FOLDER_DESCRIPTION_LENGTH,
+ max_channel_folder_name_length: realm.max_channel_folder_name_length,
+ max_channel_folder_description_length: realm.max_channel_folder_description_length,
});
function create_channel_folder(): void {
diff --git a/zerver/lib/events.py b/zerver/lib/events.py
index 9e02b323b6e..a5fb11aa22c 100644
--- a/zerver/lib/events.py
+++ b/zerver/lib/events.py
@@ -89,6 +89,7 @@ from zerver.lib.users import (
)
from zerver.lib.utils import optional_bytes_to_mib
from zerver.models import (
+ ChannelFolder,
Client,
CustomProfileField,
Draft,
@@ -560,6 +561,8 @@ def fetch_initial_state_data(
state["max_bulk_new_subscription_messages"] = settings.MAX_BULK_NEW_SUBSCRIPTION_MESSAGES
state["max_topic_length"] = MAX_TOPIC_NAME_LENGTH
state["max_message_length"] = settings.MAX_MESSAGE_LENGTH
+ state["max_channel_folder_name_length"] = ChannelFolder.MAX_NAME_LENGTH
+ state["max_channel_folder_description_length"] = ChannelFolder.MAX_DESCRIPTION_LENGTH
if realm.demo_organization_scheduled_deletion_date is not None:
state["demo_organization_scheduled_deletion_date"] = datetime_to_timestamp(
realm.demo_organization_scheduled_deletion_date
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index ea1bff9dd7d..59b5469b033 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -16282,6 +16282,28 @@ paths:
**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 a value of 1024.
+ max_channel_folder_name_length:
+ type: integer
+ description: |
+ Present if `realm` is present in `fetch_event_types`.
+
+ The maximum allowed length for a channel folder name, in Unicode
+ code points. Clients should use this property rather than hardcoding
+ field sizes.
+
+ **Changes**: New in Zulip 11.0 (feature level 410). Clients should use
+ 60 as a fallback value on previous feature levels.
+ max_channel_folder_description_length:
+ type: integer
+ description: |
+ Present if `realm` is present in `fetch_event_types`.
+
+ The maximum allowed length for a channel folder description, in
+ Unicode code points. Clients should use this property rather than
+ hardcoding field sizes.
+
+ **Changes**: New in Zulip 11.0 (feature level 410). Clients should use
+ 1024 as a fallback value on previous feature levels.
max_topic_length:
type: integer
description: |
@@ -24291,11 +24313,19 @@ paths:
name:
description: |
The name of the channel folder.
+
+ Clients should use the `max_channel_folder_name_length` returned
+ by the [`POST /register`](/api/register-queue) endpoint to determine
+ the maximum channel folder name length.
type: string
example: marketing
description:
description: |
The description of the channel folder.
+
+ Clients should use the `max_channel_folder_description_length`
+ returned by the [`POST /register`](/api/register-queue) endpoint
+ to determine the maximum channel folder description length.
type: string
example: Channels for marketing.
responses:
diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py
index 1b44bda878f..673af9460db 100644
--- a/zerver/tests/test_home.py
+++ b/zerver/tests/test_home.py
@@ -97,6 +97,8 @@ class HomeTest(ZulipTestCase):
"jitsi_server_url",
"last_event_id",
"max_avatar_file_size_mib",
+ "max_channel_folder_description_length",
+ "max_channel_folder_name_length",
"max_file_upload_size_mib",
"max_icon_file_size_mib",
"max_logo_file_size_mib",