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: Add max_message_length field to API data.

Zeeshan Equbal2da4443cc594
diff --git a/templates/zerver/api/changelog.md b/templates/zerver/api/changelog.md
index 3451fd304f0..e9b2e56d967 100644
--- a/templates/zerver/api/changelog.md
+++ b/templates/zerver/api/changelog.md
@@ -13,7 +13,7 @@ below features are supported.
**Feature level 53**
* [`POST /register`](/api/register-queue): Added `max_topic_length`
- and renamed `max_stream_name_length` and
+ and `max_message_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.
diff --git a/zerver/lib/events.py b/zerver/lib/events.py
index 1c64fdcfcdd..1a0891ea9cc 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_MESSAGE_LENGTH,
MAX_TOPIC_NAME_LENGTH,
Client,
CustomProfileField,
@@ -254,6 +255,7 @@ def fetch_initial_state_data(
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
+ state["max_message_length"] = MAX_MESSAGE_LENGTH
if want("realm_domains"):
state["realm_domains"] = get_realm_domains(realm)
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index 97bae97f594..e9f570a3230 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -6920,6 +6920,17 @@ paths:
**Changes**: New in Zulip 4.0 (feature level 53). Previously,
this always had value 60.
+ max_message_length:
+ type: integer
+ description: |
+ Present if `realm` is present in `fetch_event_types`.
+
+ The maximum allowed length for a message. 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 10000.
muted_topics:
type: array
description: |
diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py
index b5b4b29d2cd..925dfd040e2 100644
--- a/zerver/tests/test_home.py
+++ b/zerver/tests/test_home.py
@@ -106,6 +106,7 @@ class HomeTest(ZulipTestCase):
"max_icon_file_size",
"max_logo_file_size",
"max_message_id",
+ "max_message_length",
"max_stream_description_length",
"max_stream_name_length",
"max_topic_length",