mirror of https://github.com/zulip/zulip.git
api: Improve encoding of stream/topic max field lengths.
Previously, you had to request the `stream` event type in order to get the stream-level parameters; this was a bad design in part because the `subscription` event type has similar data and is preferred by most clients. So we move these to the `realm` object. We also add the maximum topic length, as an adjacent parameter. While changing this, we also fix these to better match the names of similar API parameters.
This commit is contained in:
parent
1b5a16bd1f
commit
4a3ad0da06
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue