users: Send user remove events on user deactivation.

Guests might lose access to deactivated users if the user
is not involved in any DM with guest. This commit adds
code to send "realm_user/remove" events for such cases.
This commit is contained in:
Sahil Batra
2023-11-13 21:41:13 +05:30
committed by Tim Abbott
parent 58461660c3
commit 45e1b32447
3 changed files with 92 additions and 11 deletions

View File

@@ -996,6 +996,12 @@ def apply_event(
user_profile.realm, person_user_id
)
state["raw_users"][person_user_id] = inaccessible_user_dict
if include_subscribers:
for sub in state["subscriptions"]:
sub["subscribers"] = [
user_id for user_id in sub["subscribers"] if user_id != person_user_id
]
else:
raise AssertionError("Unexpected event type {type}/{op}".format(**event))
elif event["type"] == "realm_bot":