feat: 重构优化2925邮箱和gmail邮箱逻辑
This commit is contained in:
@@ -352,6 +352,8 @@
|
||||
autoStepDelaySeconds: prevState.autoStepDelaySeconds,
|
||||
mailProvider: prevState.mailProvider,
|
||||
emailGenerator: prevState.emailGenerator,
|
||||
gmailBaseEmail: prevState.gmailBaseEmail,
|
||||
mail2925BaseEmail: prevState.mail2925BaseEmail,
|
||||
emailPrefix: prevState.emailPrefix,
|
||||
inbucketHost: prevState.inbucketHost,
|
||||
inbucketMailbox: prevState.inbucketMailbox,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
function createGeneratedEmailHelpers(deps = {}) {
|
||||
const {
|
||||
addLog,
|
||||
buildGeneratedAliasEmail,
|
||||
buildCloudflareTempEmailHeaders,
|
||||
CLOUDFLARE_TEMP_EMAIL_GENERATOR,
|
||||
DUCK_AUTOFILL_URL,
|
||||
@@ -16,6 +17,7 @@
|
||||
normalizeCloudflareDomain,
|
||||
normalizeCloudflareTempEmailAddress,
|
||||
normalizeEmailGenerator,
|
||||
isGeneratedAliasProvider,
|
||||
reuseOrCreateTab,
|
||||
sendToContentScript,
|
||||
setEmailState,
|
||||
@@ -185,8 +187,32 @@
|
||||
return result.email;
|
||||
}
|
||||
|
||||
async function fetchManagedAliasEmail(state, options = {}) {
|
||||
throwIfStopped();
|
||||
const provider = String(options.mailProvider || state?.mailProvider || '').trim().toLowerCase();
|
||||
const mergedState = {
|
||||
...(state || {}),
|
||||
mailProvider: provider,
|
||||
};
|
||||
if (options.gmailBaseEmail !== undefined) {
|
||||
mergedState.gmailBaseEmail = String(options.gmailBaseEmail || '').trim();
|
||||
}
|
||||
if (options.mail2925BaseEmail !== undefined) {
|
||||
mergedState.mail2925BaseEmail = String(options.mail2925BaseEmail || '').trim();
|
||||
}
|
||||
|
||||
const email = buildGeneratedAliasEmail(mergedState);
|
||||
await setEmailState(email);
|
||||
await addLog(`${provider === 'gmail' ? 'Gmail +tag' : '2925'}:已生成 ${email}`, 'ok');
|
||||
return email;
|
||||
}
|
||||
|
||||
async function fetchGeneratedEmail(state, options = {}) {
|
||||
const currentState = state || await getState();
|
||||
const provider = String(options.mailProvider || currentState.mailProvider || '').trim().toLowerCase();
|
||||
if (isGeneratedAliasProvider?.(provider)) {
|
||||
return fetchManagedAliasEmail(currentState, options);
|
||||
}
|
||||
const generator = normalizeEmailGenerator(options.generator ?? currentState.emailGenerator);
|
||||
if (generator === 'custom') {
|
||||
throw new Error('当前邮箱生成方式为自定义邮箱,请直接填写注册邮箱。');
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
ensureHotmailAccountForFlow,
|
||||
ensureLuckmailPurchaseForFlow,
|
||||
isGeneratedAliasProvider,
|
||||
isReusableGeneratedAliasEmail,
|
||||
isHotmailProvider,
|
||||
isLuckmailProvider,
|
||||
isSignupEmailVerificationPageUrl,
|
||||
@@ -162,7 +163,9 @@
|
||||
const purchase = await ensureLuckmailPurchaseForFlow({ allowReuse: true });
|
||||
resolvedEmail = purchase.email_address;
|
||||
} else if (isGeneratedAliasProvider(state)) {
|
||||
resolvedEmail = buildGeneratedAliasEmail(state);
|
||||
if (!isReusableGeneratedAliasEmail?.(state, resolvedEmail)) {
|
||||
resolvedEmail = buildGeneratedAliasEmail(state);
|
||||
}
|
||||
}
|
||||
|
||||
if (!resolvedEmail) {
|
||||
|
||||
Reference in New Issue
Block a user