mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
profile: Send operation in the event.
This allows us to show a useful message in the handler when the event is received.
This commit is contained in:
@@ -4507,16 +4507,17 @@ def check_attachment_reference_change(prev_content: Text, message: Message) -> N
|
||||
if len(to_add) > 0:
|
||||
do_claim_attachments(message)
|
||||
|
||||
def notify_realm_custom_profile_fields(realm: Realm) -> None:
|
||||
def notify_realm_custom_profile_fields(realm: Realm, operation: str) -> 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])
|
||||
send_event(event, active_user_ids(realm.id))
|
||||
|
||||
def try_add_realm_custom_profile_field(realm: Realm, name: Text, field_type: int) -> CustomProfileField:
|
||||
field = CustomProfileField(realm=realm, name=name, field_type=field_type)
|
||||
field.save()
|
||||
notify_realm_custom_profile_fields(realm)
|
||||
notify_realm_custom_profile_fields(realm, 'add')
|
||||
return field
|
||||
|
||||
def do_remove_realm_custom_profile_field(realm: Realm, field: CustomProfileField) -> None:
|
||||
@@ -4525,13 +4526,13 @@ 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)
|
||||
notify_realm_custom_profile_fields(realm, 'delete')
|
||||
|
||||
def try_update_realm_custom_profile_field(realm: Realm, field: CustomProfileField,
|
||||
name: Text) -> None:
|
||||
field.name = name
|
||||
field.save(update_fields=['name'])
|
||||
notify_realm_custom_profile_fields(realm)
|
||||
notify_realm_custom_profile_fields(realm, 'update')
|
||||
|
||||
def do_update_user_custom_profile_data(user_profile: UserProfile,
|
||||
data: List[Dict[str, Union[int, Text]]]) -> None:
|
||||
|
||||
Reference in New Issue
Block a user