Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
custom_profile_fields: Remove op field for the event.
shanukunbc2d58ad4a61
diff --git a/frontend_tests/node_tests/dispatch.js b/frontend_tests/node_tests/dispatch.jsindex 08a20de7fd6..ddd5dc42cad 100644--- a/frontend_tests/node_tests/dispatch.js+++ b/frontend_tests/node_tests/dispatch.js@@ -180,7 +180,7 @@ run_test("user groups", (override) => {});run_test("custom profile fields", (override) => {- const event = event_fixtures.custom_profile_fields__update;+ const event = event_fixtures.custom_profile_fields;override(settings_profile_fields, "populate_profile_fields", noop);override(settings_account, "add_custom_profile_fields_to_settings", noop);dispatch(event);diff --git a/frontend_tests/node_tests/lib/events.js b/frontend_tests/node_tests/lib/events.jsindex bf31860b788..70456616678 100644--- a/frontend_tests/node_tests/lib/events.js+++ b/frontend_tests/node_tests/lib/events.js@@ -111,12 +111,11 @@ exports.fixtures = {upload_space_used: 90000,},- custom_profile_fields__update: {+ custom_profile_fields: {type: "custom_profile_fields",- op: "update",fields: [- {id: 1, name: "teams", type: 1},- {id: 2, name: "hobbies", type: 1},+ {id: 1, name: "teams", type: 1, hint: "", field_data: "", order: 1},+ {id: 2, name: "hobbies", type: 1, hint: "", field_data: "", order: 2},],},diff --git a/templates/zerver/api/changelog.md b/templates/zerver/api/changelog.mdindex 600ddd20320..acb8ff3b6a1 100644--- a/templates/zerver/api/changelog.md+++ b/templates/zerver/api/changelog.md@@ -10,6 +10,13 @@ below features are supported.## Changes in Zulip 4.0+**Feature level 45**++* [`GET /events`](/api/get-events): Removed useless `op` field from+ `custom_profile_fields` events. These events contain the full set+ of configured `custom_profile_fields` for the organization+ regardless of what triggered the change.+**Feature level 44*** [`POST /register`](/api/register-queue): extended the `unread_msgs`diff --git a/version.py b/version.pyindex 272d24c63b6..d5a9c2c46b2 100644--- a/version.py+++ b/version.py@@ -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 = 44+API_FEATURE_LEVEL = 45# 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. Bumpdiff --git a/zerver/lib/actions.py b/zerver/lib/actions.pyindex a73e6180632..376a7b35aa3 100644--- a/zerver/lib/actions.py+++ b/zerver/lib/actions.py@@ -6715,9 +6715,9 @@ def check_attachment_reference_change(message: Message) -> bool:return message.attachment_set.exists()-def notify_realm_custom_profile_fields(realm: Realm, operation: str) -> None:+def notify_realm_custom_profile_fields(realm: Realm) -> None:fields = custom_profile_fields_for_realm(realm.id)- event = dict(type="custom_profile_fields", op=operation, fields=[f.as_dict() for f in fields])+ event = dict(type="custom_profile_fields", fields=[f.as_dict() for f in fields])send_event(realm, event, active_user_ids(realm.id))@@ -6735,7 +6735,7 @@ def try_add_realm_default_custom_profile_field(field.save()field.order = field.idfield.save(update_fields=["order"])- notify_realm_custom_profile_fields(realm, "add")+ notify_realm_custom_profile_fields(realm)return field@@ -6757,7 +6757,7 @@ def try_add_realm_custom_profile_field(field.save()field.order = field.idfield.save(update_fields=["order"])- notify_realm_custom_profile_fields(realm, "add")+ notify_realm_custom_profile_fields(realm)return field@@ -6767,7 +6767,7 @@ def do_remove_realm_custom_profile_field(realm: Realm, field: CustomProfileFieldassociated with it in CustomProfileFieldValue model."""field.delete()- notify_realm_custom_profile_fields(realm, "delete")+ notify_realm_custom_profile_fields(realm)def do_remove_realm_custom_profile_fields(realm: Realm) -> None:@@ -6789,7 +6789,7 @@ def try_update_realm_custom_profile_field():field.field_data = orjson.dumps(field_data or {}).decode()field.save()- notify_realm_custom_profile_fields(realm, "update")+ notify_realm_custom_profile_fields(realm)def try_reorder_realm_custom_profile_fields(realm: Realm, order: List[int]) -> None:@@ -6801,7 +6801,7 @@ def try_reorder_realm_custom_profile_fields(realm: Realm, order: List[int]) -> Nfor field in fields:field.order = order_mapping[field.id]field.save(update_fields=["order"])- notify_realm_custom_profile_fields(realm, "update")+ notify_realm_custom_profile_fields(realm)def notify_user_update_custom_profile_data(diff --git a/zerver/lib/event_schema.py b/zerver/lib/event_schema.pyindex 3e471aa3b42..35d9ee9f612 100644--- a/zerver/lib/event_schema.py+++ b/zerver/lib/event_schema.py@@ -184,7 +184,6 @@ custom_profile_field_type = DictType(custom_profile_fields_event = event_dict_type(required_keys=[("type", Equals("custom_profile_fields")),- ("op", Equals("add")),("fields", ListType(custom_profile_field_type)),])diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yamlindex db526abaf77..9b71e01efe4 100644--- a/zerver/openapi/zulip.yaml+++ b/zerver/openapi/zulip.yaml@@ -1390,10 +1390,6 @@ paths:- $ref: "#/components/schemas/EventTypeSchema"- enum:- custom_profile_fields- op:- type: string- enum:- - addfields:type: arraydescription: |@@ -1405,7 +1401,6 @@ paths:example:{"type": "custom_profile_fields",- "op": "add","fields":[{diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.pyindex e0aad2112f3..757776d8855 100644--- a/zerver/tests/test_events.py+++ b/zerver/tests/test_events.py@@ -65,6 +65,7 @@ from zerver.lib.actions import (do_remove_default_stream,do_remove_default_stream_group,do_remove_reaction,+ do_remove_realm_custom_profile_field,do_remove_realm_domain,do_remove_realm_emoji,do_remove_realm_filter,@@ -92,6 +93,7 @@ from zerver.lib.actions import (lookup_default_stream_groups,notify_realm_custom_profile_fields,remove_members_from_user_group,+ try_add_realm_custom_profile_field,try_update_realm_custom_profile_field,)from zerver.lib.event_schema import (@@ -165,6 +167,7 @@ from zerver.lib.test_helpers import (from zerver.lib.topic import TOPIC_NAMEfrom zerver.models import (Attachment,+ CustomProfileField,Message,MultiuseInvite,PreregistrationUser,@@ -694,20 +697,32 @@ class NormalActionsTest(BaseAction):check_typing_stop("events[0]", events[0])def test_custom_profile_fields_events(self) -> None:+ realm = self.user_profile.realm+ try_add_realm_custom_profile_field(+ realm=realm, name="Expertise", field_type=CustomProfileField.LONG_TEXT+ )+events = self.verify_action(- lambda: notify_realm_custom_profile_fields(self.user_profile.realm, "add"),+ lambda: notify_realm_custom_profile_fields(self.user_profile.realm),state_change_expected=False,)check_custom_profile_fields("events[0]", events[0])- realm = self.user_profile.realmfield = realm.customprofilefield_set.get(realm=realm, name="Biography")name = field.namehint = "Biography of the user"try_update_realm_custom_profile_field(realm, field, name, hint=hint)events = self.verify_action(- lambda: notify_realm_custom_profile_fields(self.user_profile.realm, "add"),+ lambda: notify_realm_custom_profile_fields(self.user_profile.realm),+ state_change_expected=False,+ )+ check_custom_profile_fields("events[0]", events[0])++ do_remove_realm_custom_profile_field(realm, field)++ events = self.verify_action(+ lambda: notify_realm_custom_profile_fields(self.user_profile.realm),state_change_expected=False,)check_custom_profile_fields("events[0]", events[0])