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 `server_report_message_types` to `realm`.

PieterCK6e73430060e2
diff --git a/api_docs/changelog.md b/api_docs/changelog.md
index 141b6f893d1..8cf4c127291 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 12.0
+**Feature level 435**
+
+* [`POST /register`](/api/register-queue): Added `server_report_message_types`
+ field which contains a list of supported report types for the [message
+ report](/help/report-a-message) feature.
+
**Feature level 434**
* [`POST /register`](/api/register-queue), [`POST /events`](/api/get-events),
diff --git a/version.py b/version.py
index 7ab63677f21..5536cdef8dc 100644
--- a/version.py
+++ b/version.py
@@ -35,7 +35,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 = 434
+API_FEATURE_LEVEL = 435
# 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/state_data.ts b/web/src/state_data.ts
index e1c97b0203c..ecf3767d3fa 100644
--- a/web/src/state_data.ts
+++ b/web/src/state_data.ts
@@ -326,6 +326,11 @@ export const realm_linkifier_schema = z.object({
id: z.number(),
});
+export const realm_report_message_types = z.object({
+ key: z.string(),
+ name: z.string(),
+});
+
// Sync this with zerver.lib.events.do_events_register.
export const realm_schema = z.object({
custom_profile_fields: z.array(custom_profile_field_schema),
@@ -504,6 +509,7 @@ export const realm_schema = z.object({
server_needs_upgrade: z.boolean(),
server_presence_offline_threshold_seconds: z.number(),
server_presence_ping_interval_seconds: z.number(),
+ server_report_message_types: z.array(realm_report_message_types),
server_supported_permission_settings: z.object({
realm: z.record(z.string(), group_permission_setting_schema),
stream: z.record(z.string(), group_permission_setting_schema),
diff --git a/zerver/lib/events.py b/zerver/lib/events.py
index cecf5967214..a52a80a33ba 100644
--- a/zerver/lib/events.py
+++ b/zerver/lib/events.py
@@ -570,6 +570,11 @@ def fetch_initial_state_data(
)
state["realm_date_created"] = datetime_to_timestamp(realm.date_created)
+ state["server_report_message_types"] = [
+ {"key": type_id, "name": str(type_name)}
+ for type_id, type_name in Realm.REPORT_MESSAGE_REASONS.items()
+ ]
+
# Presence system parameters for client behavior.
state["server_presence_ping_interval_seconds"] = settings.PRESENCE_PING_INTERVAL_SECS
state["server_presence_offline_threshold_seconds"] = settings.OFFLINE_THRESHOLD_SECS
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index ccf72ff6070..72cb5551108 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -21398,6 +21398,31 @@ paths:
avatar_version: {}
profile_data: {}
is_imported_stub: {}
+ server_report_message_types:
+ description: |
+ Present if `realm` is present in `fetch_event_types`.
+
+ A list of objects where each object describes a supported
+ report type for the [message report](/help/report-a-message)
+ feature.
+
+ **Changes**: New in Zulip 12.0 (feature level 435).
+ type: array
+ items:
+ type: object
+ additionalProperties: false
+ properties:
+ key:
+ type: string
+ description: |
+ The unique ID for the report message type.
+ name:
+ type: string
+ description: |
+ The user-facing string for the report message type, to be
+ displayed in the report message UI, in the user's language.
+ Note that the actual report will use the name for this type
+ in the organization's default language.
server_supported_permission_settings:
description: |
Present if `realm` is present in `fetch_event_types`.
diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py
index a4ed1994b94..64e4d8b11f4 100644
--- a/zerver/tests/test_home.py
+++ b/zerver/tests/test_home.py
@@ -245,6 +245,7 @@ class HomeTest(ZulipTestCase):
"server_needs_upgrade",
"server_presence_offline_threshold_seconds",
"server_presence_ping_interval_seconds",
+ "server_report_message_types",
"server_supported_permission_settings",
"server_thumbnail_formats",
"server_timestamp",