fix: sync LuckMail PR with dev

This commit is contained in:
QLHazyCoder
2026-04-29 22:12:28 +08:00
52 changed files with 8013 additions and 909 deletions
+38 -2
View File
@@ -222,6 +222,28 @@
return Math.min(20, Math.max(0, Math.floor(numeric)));
}
function getVerificationRequestedAtStateKey(step) {
if (Number(step) === 4) return 'signupVerificationRequestedAt';
if (Number(step) === 8) return 'loginVerificationRequestedAt';
return '';
}
function resolveInitialVerificationRequestedAt(step, state = {}, fallback = 0) {
const stateKey = getVerificationRequestedAtStateKey(step);
const candidateValues = [
fallback,
stateKey ? state?.[stateKey] : 0,
];
for (const value of candidateValues) {
const numeric = Number(value);
if (Number.isFinite(numeric) && numeric > 0) {
return Math.floor(numeric);
}
}
return 0;
}
function getLegacyVerificationResendCountDefault(step, options = {}) {
const requestFreshCodeFirst = Boolean(options.requestFreshCodeFirst);
const legacyMaxRounds = Math.max(1, Math.floor(Number(VERIFICATION_POLL_MAX_ROUNDS) || 1));
@@ -985,9 +1007,23 @@
: getConfiguredVerificationResendCount(step, state, { requestFreshCodeFirst });
const maxSubmitAttempts = mail.provider === LUCKMAIL_PROVIDER ? 3 : 15;
const resendIntervalMs = Math.max(0, Number(options.resendIntervalMs) || 0);
let lastResendAt = Number(options.lastResendAt) || 0;
const externalOnResendRequestedAt = typeof options.onResendRequestedAt === 'function'
? options.onResendRequestedAt
: null;
let lastResendAt = resolveInitialVerificationRequestedAt(
step,
state,
Number(options.lastResendAt) || 0
);
const updateFilterAfterTimestampForVerificationStep = async (_requestedAt) => {
const updateFilterAfterTimestampForVerificationStep = async (requestedAt) => {
if (externalOnResendRequestedAt) {
try {
await externalOnResendRequestedAt(requestedAt);
} catch (_) {
// Keep resend flow best-effort; state sync callback failures should not break verification.
}
}
return nextFilterAfterTimestamp;
};