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.

realm: Fix event sent when updating description.

Sahil Batra2c4c8b1fe61b
diff --git a/api_docs/changelog.md b/api_docs/changelog.md
index 6bec71bb2f4..1400aab57f4 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 464**
+
+* [`GET /events`](/api/get-events): The server now sends a
+ `realm/update_dict` event instead of `realm/update` event when a
+ Realm's `description` property is changed.
+
**Feature level 463**
* [`GET /bots/{bot_id}/api_key`](/api/get-bot-api-key): Added
@@ -27,8 +33,10 @@ format used by the Zulip server that they are interacting with.
**Feature level 462**
-* [`GET /events`](/api/get-events): Added `rendered_description` field to the
- realm update event when the `description` property is changed.
+* [`GET /events`](/api/get-events): Added `rendered_description` field
+ to the realm update event when the `description` property is
+ changed. Note that this new field was removed and replaced with the
+ standard `update_dict` mechanism in feature level 464.
**Feature level 461**
diff --git a/version.py b/version.py
index 63f17c71fc0..0b1f39ca5ec 100644
--- a/version.py
+++ b/version.py
@@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.9.3"
# https://zulip.readthedocs.io/en/latest/documentation/api.html#step-by-step-guide
# Also available at docs/documentation/api.md.
-API_FEATURE_LEVEL = 463
+API_FEATURE_LEVEL = 464
# 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/actions/realm_settings.py b/zerver/actions/realm_settings.py
index 5d50df58518..1964b6adcb9 100644
--- a/zerver/actions/realm_settings.py
+++ b/zerver/actions/realm_settings.py
@@ -102,9 +102,6 @@ def do_set_realm_property(
value=value,
)
- if name == "description":
- event["rendered_description"] = realm.rendered_description
-
# These settings have a different event format due to their history.
message_edit_settings = [
"allow_message_editing",
@@ -134,6 +131,16 @@ def do_set_realm_property(
"mandatory_topics": value == RealmTopicsPolicyEnum.disable_empty_topic.value,
},
)
+ if name == "description":
+ event = dict(
+ type="realm",
+ op="update_dict",
+ property="default",
+ data={
+ "description": realm.description,
+ "rendered_description": realm.rendered_description,
+ },
+ )
send_event_on_commit(realm, event, active_user_ids(realm.id))
diff --git a/zerver/lib/event_schema.py b/zerver/lib/event_schema.py
index f9aac368267..3bec42a18f9 100644
--- a/zerver/lib/event_schema.py
+++ b/zerver/lib/event_schema.py
@@ -119,6 +119,7 @@ from zerver.lib.event_types import (
PersonRole,
PersonTimezone,
PlanTypeData,
+ RealmDescriptionData,
RealmTopicsPolicyData,
)
from zerver.lib.topic import ORIG_TOPIC, TOPIC_NAME
@@ -465,10 +466,6 @@ def check_realm_update(
assert prop == event["property"]
value = event["value"]
- if prop == "description":
- assert "rendered_description" in event
- assert isinstance(event["rendered_description"], str)
-
if prop in [
"moderation_request_channel_id",
"new_stream_announcements_stream_id",
@@ -531,6 +528,8 @@ def check_realm_update_dict(
sub_type = PlanTypeData
elif "topics_policy" in event["data"]:
sub_type = RealmTopicsPolicyData
+ elif "description" in event["data"]:
+ sub_type = RealmDescriptionData
else:
raise AssertionError("unhandled fields in data")
diff --git a/zerver/lib/event_types.py b/zerver/lib/event_types.py
index 10f57795f4e..7729a1d9534 100644
--- a/zerver/lib/event_types.py
+++ b/zerver/lib/event_types.py
@@ -586,6 +586,11 @@ class RealmTopicsPolicyData(BaseModel):
mandatory_topics: bool
+class RealmDescriptionData(BaseModel):
+ description: str
+ rendered_description: str
+
+
class NightLogoData(BaseModel):
night_logo_url: str
night_logo_source: str
diff --git a/zerver/lib/events.py b/zerver/lib/events.py
index fa142ec95af..dc63e39d5a8 100644
--- a/zerver/lib/events.py
+++ b/zerver/lib/events.py
@@ -1532,6 +1532,13 @@ def apply_event(
state["max_file_upload_size_mib"] = value
continue
+ if key == "rendered_description":
+ # realm_rendered_description field is not included in
+ # the state data returned by fetch_initial_state_data,
+ # and is added separately to the page_params data
+ # returned to clients in build_page_params_for_home_load.
+ continue
+
state["realm_" + key] = value
# It's a bit messy, but this is where we need to
# update the state for whether password authentication
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index bcff7fa90ef..84503260462 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -4427,11 +4427,14 @@ paths:
events into the corresponding [realm/update_dict](#realm-update_dict)
event and then process that.
- **Changes**: Removed `extra_data` optional property in Zulip 10.0
- (feature level 306). The `extra_data` used to include an
- `upload_quota` field when changed property was `plan_type`. The
- server now sends a standard `realm/update_dict` event for plan
- changes.
+ **Changes**: Removed the `rendered_description` property in
+ Zulip 12.0 (feature level 464). It had been briefly present only
+ since feature level 462 and can be safely ignored by all clients.
+
+ Removed `extra_data` optional property in Zulip 10.0 (feature level 306).
+ The `extra_data` used to include an `upload_quota` field when changed
+ property was `plan_type`. The server now sends a standard
+ `realm/update_dict` event for plan changes.
properties:
id:
$ref: "#/components/schemas/EventIdSchema"
@@ -4456,21 +4459,6 @@ paths:
- type: boolean
- type: integer
nullable: true
- rendered_description:
- type: string
- description: |
- Note: Only present if the changed property was `description`.
-
- The organization description rendered as HTML, intended to
- be used when displaying the organization description in a UI.
-
- One should use the standard Zulip rendered_markdown CSS when
- displaying this content so that emoji, LaTeX, and other syntax
- work correctly. And any client-side security logic for
- user-generated message content should be applied when displaying
- this HTML as though it were the body of a Zulip message.
-
- **Changes**: New in Zulip 12.0 (feature level 462).
example:
{
"type": "realm",
@@ -5419,6 +5407,23 @@ paths:
indicated timestamp is near.
**Changes**: New in Zulip 8.0 (feature level 231).
+ rendered_description:
+ type: string
+ description: |
+ Note: Only present if the changed property was `description`.
+
+ The organization description rendered as HTML, intended to
+ be used when displaying the organization description in a UI.
+
+ One should use the standard Zulip rendered_markdown CSS when
+ displaying this content so that emoji, LaTeX, and other syntax
+ work correctly. And any client-side security logic for
+ user-generated message content should be applied when displaying
+ this HTML as though it were the body of a Zulip message.
+
+ **Changes**: New in Zulip 12.0 (feature level 464). Previously
+ in feature levels 462-463, an `update` event had been sent
+ when updating the realm's `description`.
require_e2ee_push_notifications:
type: boolean
description: |
diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py
index 791b95af381..09d2f646832 100644
--- a/zerver/tests/test_events.py
+++ b/zerver/tests/test_events.py
@@ -4476,6 +4476,7 @@ class RealmPropertyActionTest(BaseAction):
"allow_message_editing",
"message_content_edit_limit_seconds",
"topics_policy",
+ "description",
]:
check_realm_update_dict("events[0]", events[0])
else:
diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py
index 8ad89da22dc..803b97ee3b3 100644
--- a/zerver/tests/test_realm.py
+++ b/zerver/tests/test_realm.py
@@ -215,10 +215,12 @@ class RealmTest(ZulipTestCase):
event,
dict(
type="realm",
- op="update",
- property="description",
- value=new_description,
- rendered_description=f"<p>{new_description}</p>",
+ op="update_dict",
+ property="default",
+ data={
+ "description": new_description,
+ "rendered_description": f"<p>{new_description}</p>",
+ },
),
)
@@ -237,10 +239,12 @@ class RealmTest(ZulipTestCase):
event,
dict(
type="realm",
- op="update",
- property="description",
- value=new_description,
- rendered_description=f"<p>{new_description}</p>",
+ op="update_dict",
+ property="default",
+ data={
+ "description": new_description,
+ "rendered_description": f"<p>{new_description}</p>",
+ },
),
)