修复自定义邮箱收码模式默认手动

This commit is contained in:
QLHazyCoder
2026-05-28 06:14:04 +08:00
parent 1960b6e21a
commit 2992cc88ac
18 changed files with 1154 additions and 6 deletions
+22
View File
@@ -69,6 +69,7 @@
chrome = (typeof globalThis !== 'undefined' ? globalThis.chrome : null),
CLOUDFLARE_TEMP_EMAIL_PROVIDER = 'cloudflare-temp-email',
CLOUD_MAIL_PROVIDER = 'cloudmail',
CUSTOM_MAIL_PROVIDER = 'custom',
ensureIcloudMailSession = null,
ensureMail2925MailboxSession = null,
getMailConfig = null,
@@ -81,11 +82,13 @@
LUCKMAIL_PROVIDER = 'luckmail-api',
pollCloudflareTempEmailVerificationCode = null,
pollCloudMailVerificationCode = null,
pollCustomMailVerificationCode = null,
pollHotmailVerificationCode = null,
pollLuckmailVerificationCode = null,
pollYydsMailVerificationCode = null,
reuseOrCreateTab = async () => null,
sendToMailContentScriptResilient = null,
shouldUseCustomMailHelper = null,
throwIfStopped = () => {},
YYDS_MAIL_PROVIDER = 'yyds-mail',
} = deps;
@@ -107,6 +110,10 @@
label: 'Cloud Mail',
poll: pollCloudMailVerificationCode,
}],
[normalizeProviderId(CUSTOM_MAIL_PROVIDER), {
label: '自定义邮箱本地助手',
poll: pollCustomMailVerificationCode,
}],
[normalizeProviderId(YYDS_MAIL_PROVIDER), {
label: 'YYDS Mail',
poll: pollYydsMailVerificationCode,
@@ -167,11 +174,26 @@
return normalizeProviderId(mail?.provider) === '2925';
}
function isCustomMailProvider(mail = {}) {
return normalizeProviderId(mail?.provider) === normalizeProviderId(CUSTOM_MAIL_PROVIDER);
}
function canUseCustomMailHelper(state = {}) {
if (typeof shouldUseCustomMailHelper === 'function') {
return Boolean(shouldUseCustomMailHelper(state));
}
return normalizeProviderId(state?.mailProvider) === normalizeProviderId(CUSTOM_MAIL_PROVIDER)
&& normalizeProviderId(state?.customMailReceiveMode) === 'helper';
}
async function pollThroughApiProvider(providerId, step, state, pollPayload, mail, options) {
const handler = apiProviderHandlers.get(providerId);
if (!handler) {
return null;
}
if (isCustomMailProvider(mail) && !canUseCustomMailHelper(state)) {
throw new Error('自定义邮箱当前为手动确认模式,未启用本地 helper 自动收码。');
}
if (typeof handler.poll !== 'function') {
throw new Error(`${handler.label} 邮箱轮询能力未接入,无法继续执行。`);
}
+9
View File
@@ -12,6 +12,7 @@
closeConflictingTabsForSource,
CLOUDFLARE_TEMP_EMAIL_PROVIDER,
CLOUD_MAIL_PROVIDER = 'cloudmail',
CUSTOM_MAIL_PROVIDER = 'custom',
completeNodeFromBackground,
confirmCustomVerificationStepBypassRequest,
getNodeIdByStepForState,
@@ -29,6 +30,7 @@
MAIL_2925_VERIFICATION_MAX_ATTEMPTS,
pollCloudflareTempEmailVerificationCode,
pollCloudMailVerificationCode,
pollCustomMailVerificationCode,
pollHotmailVerificationCode,
pollLuckmailVerificationCode,
pollYydsMailVerificationCode,
@@ -987,6 +989,13 @@
}, cleanPollOverrides, `轮询${getVerificationCodeLabel(step)}验证码邮箱`);
return pollCloudMailVerificationCode(step, state, timedPoll.payload);
}
if (mail.provider === CUSTOM_MAIL_PROVIDER && typeof pollCustomMailVerificationCode === 'function') {
const timedPoll = await applyMailPollingTimeBudget(step, {
...getVerificationPollPayload(step, state),
...cleanPollOverrides,
}, cleanPollOverrides, `轮询${getVerificationCodeLabel(step)}验证码邮箱`);
return pollCustomMailVerificationCode(step, state, timedPoll.payload);
}
if (mail.provider === YYDS_MAIL_PROVIDER) {
const timedPoll = await applyMailPollingTimeBudget(step, {
...getVerificationPollPayload(step, state),