mirror of https://github.com/zulip/zulip.git
realm_settings: Update do_set...default_setting to send event on commit.
Earlier, we were using 'send_event' in do_set_realm_user_default_setting 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
8ddaa949fc
commit
63064e926b
|
@ -452,6 +452,7 @@ def do_set_realm_zulip_update_announcements_stream(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@transaction.atomic(durable=True)
|
||||||
def do_set_realm_user_default_setting(
|
def do_set_realm_user_default_setting(
|
||||||
realm_user_default: RealmUserDefault,
|
realm_user_default: RealmUserDefault,
|
||||||
name: str,
|
name: str,
|
||||||
|
@ -463,7 +464,6 @@ def do_set_realm_user_default_setting(
|
||||||
realm = realm_user_default.realm
|
realm = realm_user_default.realm
|
||||||
event_time = timezone_now()
|
event_time = timezone_now()
|
||||||
|
|
||||||
with transaction.atomic(savepoint=False):
|
|
||||||
setattr(realm_user_default, name, value)
|
setattr(realm_user_default, name, value)
|
||||||
realm_user_default.save(update_fields=[name])
|
realm_user_default.save(update_fields=[name])
|
||||||
|
|
||||||
|
@ -485,7 +485,7 @@ def do_set_realm_user_default_setting(
|
||||||
property=name,
|
property=name,
|
||||||
value=value,
|
value=value,
|
||||||
)
|
)
|
||||||
send_event(realm, event, active_user_ids(realm.id))
|
send_event_on_commit(realm, event, active_user_ids(realm.id))
|
||||||
|
|
||||||
|
|
||||||
RealmDeactivationReasonType = Literal[
|
RealmDeactivationReasonType = Literal[
|
||||||
|
|
Loading…
Reference in New Issue