actions: Use transaction.atomic for do_change_default_all_public_streams.

This commit is contained in:
Sahil Batra
2022-01-03 15:44:50 +05:30
committed by Tim Abbott
parent 4a7461361e
commit cb43bdab93

View File

@@ -4895,6 +4895,7 @@ def do_change_default_events_register_stream(
)
@transaction.atomic(durable=True)
def do_change_default_all_public_streams(
user_profile: UserProfile, value: bool, *, acting_user: Optional[UserProfile]
) -> None:
@@ -4918,18 +4919,21 @@ def do_change_default_all_public_streams(
)
if user_profile.is_bot:
send_event(
user_profile.realm,
dict(
event = dict(
type="realm_bot",
op="update",
bot=dict(
user_id=user_profile.id,
default_all_public_streams=user_profile.default_all_public_streams,
),
),
)
transaction.on_commit(
lambda: send_event(
user_profile.realm,
event,
bot_owner_user_ids(user_profile),
)
)
@transaction.atomic