invites: Stop adjusting invited_at on resends.

This commit is contained in:
Alex Vandiver 2024-05-01 04:27:32 +00:00 committed by Tim Abbott
parent d863aa56de
commit 512d53d01a
3 changed files with 5 additions and 13 deletions

View File

@ -201,12 +201,9 @@ function do_resend_invite({$row, invite_id}: {$row: JQuery; invite_id: string}):
error(xhr) {
ui_report.generic_row_button_error(xhr, $resend_button);
},
success(raw_data) {
const data = z.object({timestamp: z.number()}).parse(raw_data);
success() {
$resend_button.text($t({defaultMessage: "Sent!"}));
$resend_button.removeClass("resend btn-warning").addClass("sea-green");
const timestamp = timerender.absolute_time(data.timestamp * 1000);
$row.find(".invited_at").text(timestamp);
},
});
}

View File

@ -438,7 +438,7 @@ def do_revoke_multi_use_invite(multiuse_invite: MultiuseInvite) -> None:
@transaction.atomic
def do_resend_user_invite_email(prereg_user: PreregistrationUser) -> int:
def do_resend_user_invite_email(prereg_user: PreregistrationUser) -> None:
# Take a lock on the realm, so we can check for invitation limits without races
realm_id = assert_is_not_none(prereg_user.realm_id)
realm = Realm.objects.select_for_update().get(id=realm_id)
@ -446,16 +446,13 @@ def do_resend_user_invite_email(prereg_user: PreregistrationUser) -> int:
assert prereg_user.referred_by is not None
prereg_user.invited_at = timezone_now()
prereg_user.save()
expiry_date = prereg_user.confirmation.get().expiry_date
if expiry_date is None:
invite_expires_in_minutes = None
else:
# The resent invitation is reset to expire as long after the
# reminder is sent as it lasted originally.
invite_expires_in_minutes = (expiry_date - prereg_user.invited_at).total_seconds() / 60
invite_expires_in_minutes = (expiry_date - timezone_now()).total_seconds() / 60
prereg_user.confirmation.clear()
do_increment_logging_stat(realm, COUNT_STATS["invites_sent::day"], None, prereg_user.invited_at)
@ -469,5 +466,3 @@ def do_resend_user_invite_email(prereg_user: PreregistrationUser) -> int:
"invite_expires_in_minutes": invite_expires_in_minutes,
}
queue_event_on_commit("invites", event)
return datetime_to_timestamp(prereg_user.invited_at)

View File

@ -193,8 +193,8 @@ def resend_user_invite_email(
if prereg_user.referred_by_id != user_profile.id:
check_role_based_permissions(prereg_user.invited_as, user_profile, require_admin=True)
timestamp = do_resend_user_invite_email(prereg_user)
return json_success(request, data={"timestamp": timestamp})
do_resend_user_invite_email(prereg_user)
return json_success(request)
@require_member_or_admin