mirror of https://github.com/zulip/zulip.git
users: Send event on commit in do_change_is_billing_admin.
Earlier, we were using 'send_event' in 'do_change_is_billing_admin' which can lead to a situation, if any db operation is added after the 'send_event' in future, where we enqueue events but the action 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:
parent
2b6c5260a5
commit
3ea6ba97c0
|
@ -50,7 +50,7 @@ from zerver.models.users import (
|
|||
get_bot_dicts_in_realm,
|
||||
get_user_profile_by_id,
|
||||
)
|
||||
from zerver.tornado.django_api import send_event, send_event_on_commit
|
||||
from zerver.tornado.django_api import send_event_on_commit
|
||||
|
||||
if settings.BILLING_ENABLED:
|
||||
from corporate.lib.stripe import RealmBillingSession
|
||||
|
@ -517,13 +517,14 @@ def do_change_user_role(
|
|||
send_stream_events_for_role_update(user_profile, previously_accessible_streams)
|
||||
|
||||
|
||||
@transaction.atomic(savepoint=False)
|
||||
def do_change_is_billing_admin(user_profile: UserProfile, value: bool) -> None:
|
||||
user_profile.is_billing_admin = value
|
||||
user_profile.save(update_fields=["is_billing_admin"])
|
||||
event = dict(
|
||||
type="realm_user", op="update", person=dict(user_id=user_profile.id, is_billing_admin=value)
|
||||
)
|
||||
send_event(user_profile.realm, event, get_user_ids_who_can_access_user(user_profile))
|
||||
send_event_on_commit(user_profile.realm, event, get_user_ids_who_can_access_user(user_profile))
|
||||
|
||||
|
||||
def do_change_can_forge_sender(user_profile: UserProfile, value: bool) -> None:
|
||||
|
|
Loading…
Reference in New Issue