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( def do_change_default_all_public_streams(
user_profile: UserProfile, value: bool, *, acting_user: Optional[UserProfile] user_profile: UserProfile, value: bool, *, acting_user: Optional[UserProfile]
) -> None: ) -> None:
@@ -4918,17 +4919,20 @@ def do_change_default_all_public_streams(
) )
if user_profile.is_bot: if user_profile.is_bot:
send_event( event = dict(
user_profile.realm, type="realm_bot",
dict( op="update",
type="realm_bot", bot=dict(
op="update", user_id=user_profile.id,
bot=dict( default_all_public_streams=user_profile.default_all_public_streams,
user_id=user_profile.id,
default_all_public_streams=user_profile.default_all_public_streams,
),
), ),
bot_owner_user_ids(user_profile), )
transaction.on_commit(
lambda: send_event(
user_profile.realm,
event,
bot_owner_user_ids(user_profile),
)
) )