users: Send "update" events when deactivating or reactivating users.

We now send "realm_user/update" (and "realm_bot/update" for bots)
events with "is_active" field when deactivating and reactivating
users, including bots.

We would want to use "remove" event for a user losing access
to another user for #10970, so it is better to use "update"
event for deactivation as we only update "is_active" field
in the user objects and the clients still have the data for
deactivated users.

Previously, we used to send "add" event for reactivation along
with complete user objects, but clients should have the data
for deactivated users as well, so an "update" event is enough
like we do when deactivating users.
This commit is contained in:
Sahil Batra
2023-10-30 17:20:40 +05:30
committed by Tim Abbott
parent 5dc9b060d2
commit bb15b2d708
15 changed files with 148 additions and 134 deletions

View File

@@ -644,15 +644,6 @@ bot_type_for_remove = DictType(
]
)
realm_bot_remove_event = event_dict_type(
required_keys=[
("type", Equals("realm_bot")),
("op", Equals("remove")),
("bot", bot_type_for_remove),
]
)
check_realm_bot_remove = make_checker(realm_bot_remove_event)
bot_type_for_update = DictType(
required_keys=[
("user_id", int),
@@ -664,6 +655,7 @@ bot_type_for_update = DictType(
("default_events_register_stream", OptionalType(str)),
("default_sending_stream", OptionalType(str)),
("full_name", str),
("is_active", bool),
("owner_id", int),
("services", bot_services_type),
],
@@ -1108,15 +1100,6 @@ removed_user_type = DictType(
]
)
realm_user_remove_event = event_dict_type(
required_keys=[
("type", Equals("realm_user")),
("op", Equals("remove")),
("person", removed_user_type),
],
)
check_realm_user_remove = make_checker(realm_user_remove_event)
custom_profile_field_type = DictType(
required_keys=[
("id", int),
@@ -1190,6 +1173,12 @@ realm_user_person_types = dict(
("timezone", str),
],
),
is_active=DictType(
required_keys=[
("user_id", int),
("is_active", bool),
],
),
)
realm_user_update_event = event_dict_type(