invites: Add `durable=True` to transaction in `do_invite_users`.

This commit adds 'durable=True' to the outermost transaction
in 'do_invite_users'.

It also adds 'savepoint=False' to inner transaction.atomic
decorators to avoid creating savepoints.
This commit is contained in:
Prakhar Pratyush 2024-11-01 16:23:05 +05:30 committed by Tim Abbott
parent ea80791b96
commit 9371bdb81d
2 changed files with 3 additions and 3 deletions

View File

@ -173,7 +173,7 @@ def check_invite_limit(realm: Realm, num_invitees: int) -> None:
)
@transaction.atomic
@transaction.atomic(durable=True)
def do_invite_users(
user_profile: UserProfile,
invitee_emails: Collection[str],
@ -414,7 +414,7 @@ def do_revoke_multi_use_invite(multiuse_invite: MultiuseInvite) -> None:
notify_invites_changed(realm, changed_invite_referrer=multiuse_invite.referred_by)
@transaction.atomic
@transaction.atomic(savepoint=False)
def do_send_user_invite_email(
prereg_user: PreregistrationUser,
*,

View File

@ -378,7 +378,7 @@ def send_future_email(
# For logging the email
assert (to_user_ids is None) ^ (to_emails is None)
with transaction.atomic():
with transaction.atomic(savepoint=False):
email = ScheduledEmail.objects.create(
type=EMAIL_TYPES[template_name],
scheduled_timestamp=timezone_now() + delay,