feat: 在验证码请求流程中添加首次请求新验证码的选项,优化邮箱轮询逻辑

This commit is contained in:
QLHazyCoder
2026-04-09 01:50:12 +08:00
parent a86f6d4007
commit ed97ec4a4a
+18 -2
View File
@@ -1759,8 +1759,18 @@ async function resolveVerificationStep(step, state, mail, options = {}) {
}
let nextFilterAfterTimestamp = options.filterAfterTimestamp ?? null;
const requestFreshCodeFirst = Boolean(options.requestFreshCodeFirst);
const maxSubmitAttempts = 3;
if (requestFreshCodeFirst) {
try {
nextFilterAfterTimestamp = await requestVerificationCodeResend(step);
await addLog(`步骤 ${step}:已先请求一封新的${getVerificationCodeLabel(step)}验证码,再开始轮询邮箱。`, 'warn');
} catch (err) {
await addLog(`步骤 ${step}:首次重新获取验证码失败:${err.message},将继续使用当前时间窗口轮询。`, 'warn');
}
}
for (let attempt = 1; attempt <= maxSubmitAttempts; attempt++) {
const result = await pollFreshVerificationCode(step, state, mail, {
excludeCodes: [...rejectedCodes],
@@ -1851,7 +1861,10 @@ async function executeStep4(state) {
});
}
await resolveVerificationStep(4, state, mail, { filterAfterTimestamp: stepStartedAt });
await resolveVerificationStep(4, state, mail, {
filterAfterTimestamp: stepStartedAt,
requestFreshCodeFirst: true,
});
return;
}
@@ -1966,7 +1979,10 @@ async function executeStep7(state) {
});
}
await resolveVerificationStep(7, state, mail, { filterAfterTimestamp: stepStartedAt });
await resolveVerificationStep(7, state, mail, {
filterAfterTimestamp: stepStartedAt,
requestFreshCodeFirst: true,
});
return;
}