user_groups: Update delete_user_group codepath to send event on commit.

Earlier, we were using 'send_event' in 'delete_user_grou' codepath
which can lead to a situation, if any db operation is added after
the 'send_event' in future, where we enqueue events but the
function fails at a later stage.

Events should not be sent until we know we're not rolling back.

Fixes part of #30489.
This commit is contained in:
Prakhar Pratyush 2024-08-09 14:53:32 +05:30 committed by Tim Abbott
parent 66ff646e99
commit 427c59ec68
1 changed files with 1 additions and 1 deletions

View File

@ -425,7 +425,7 @@ def remove_subgroups_from_user_group(
def do_send_delete_user_group_event(realm: Realm, user_group_id: int, realm_id: int) -> None:
event = dict(type="user_group", op="remove", group_id=user_group_id)
send_event(realm, event, active_user_ids(realm_id))
send_event_on_commit(realm, event, active_user_ids(realm_id))
def check_delete_user_group(user_group: NamedUserGroup, *, acting_user: UserProfile) -> None: