mirror of https://github.com/zulip/zulip.git
custom_profile_fields: Remove op field for the event.
* `op` (operation) field, added in f6fb88549f
, was never intended for
`custom_profile_fields` event. This commit removes the `op` as it doesn't
have any use in the code.
* As a part of cleanup, this also eliminates the schema check warnings
for `custom_profile_fields` event, mentioned in #17568.
This commit is contained in:
parent
79586cc466
commit
bc2d58ad4a
|
@ -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);
|
||||
|
|
|
@ -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},
|
||||
],
|
||||
},
|
||||
|
||||
|
|
|
@ -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`
|
||||
|
|
|
@ -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. Bump
|
||||
|
|
|
@ -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.id
|
||||
field.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.id
|
||||
field.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: CustomProfileField
|
|||
associated 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]) -> N
|
|||
for 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(
|
||||
|
|
|
@ -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)),
|
||||
]
|
||||
)
|
||||
|
|
|
@ -1390,10 +1390,6 @@ paths:
|
|||
- $ref: "#/components/schemas/EventTypeSchema"
|
||||
- enum:
|
||||
- custom_profile_fields
|
||||
op:
|
||||
type: string
|
||||
enum:
|
||||
- add
|
||||
fields:
|
||||
type: array
|
||||
description: |
|
||||
|
@ -1405,7 +1401,6 @@ paths:
|
|||
example:
|
||||
{
|
||||
"type": "custom_profile_fields",
|
||||
"op": "add",
|
||||
"fields":
|
||||
[
|
||||
{
|
||||
|
|
|
@ -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_NAME
|
||||
from 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.realm
|
||||
field = realm.customprofilefield_set.get(realm=realm, name="Biography")
|
||||
name = field.name
|
||||
hint = "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])
|
||||
|
|
Loading…
Reference in New Issue