From 1b23cbdf3e92ad40a958b9a9c291f9c1f71cc27e Mon Sep 17 00:00:00 2001 From: Sahil Batra Date: Wed, 8 Dec 2021 19:56:33 +0530 Subject: [PATCH] do_change_user_role: Use transaction.atomic. --- zerver/lib/actions.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 5828023bc7..585a3e6f6d 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -4800,6 +4800,7 @@ def do_change_default_all_public_streams( ) +@transaction.atomic def do_change_user_role( user_profile: UserProfile, value: int, *, acting_user: Optional[UserProfile] ) -> None: @@ -4823,7 +4824,9 @@ def do_change_user_role( event = dict( type="realm_user", op="update", person=dict(user_id=user_profile.id, role=user_profile.role) ) - send_event(user_profile.realm, event, active_user_ids(user_profile.realm_id)) + transaction.on_commit( + lambda: send_event(user_profile.realm, event, active_user_ids(user_profile.realm_id)) + ) def do_make_user_billing_admin(user_profile: UserProfile) -> None: