(targetRun, totalRuns, attemptRuns)
| 4913 | } |
| 4914 | |
| 4915 | async function ensureAutoEmailReady(targetRun, totalRuns, attemptRuns) { |
| 4916 | const currentState = await getState(); |
| 4917 | if (isHotmailProvider(currentState)) { |
| 4918 | const account = await ensureHotmailAccountForFlow({ |
| 4919 | allowAllocate: true, |
| 4920 | markUsed: true, |
| 4921 | preferredAccountId: null, |
| 4922 | }); |
| 4923 | await addLog(`=== 目标 ${targetRun}/${totalRuns} 轮:已分配 Hotmail 账号 ${account.email}(第 ${attemptRuns} 次尝试)===`, 'ok'); |
| 4924 | return account.email; |
| 4925 | } |
| 4926 | |
| 4927 | if (isLuckmailProvider(currentState)) { |
| 4928 | const purchase = await ensureLuckmailPurchaseForFlow({ allowReuse: true }); |
| 4929 | await addLog(`=== 目标 ${targetRun}/${totalRuns} 轮:LuckMail 邮箱已就绪:${purchase.email_address}(第 ${attemptRuns} 次尝试)===`, 'ok'); |
| 4930 | return purchase.email_address; |
| 4931 | } |
| 4932 | |
| 4933 | if (isGeneratedAliasProvider(currentState)) { |
| 4934 | if (currentState.mailProvider === GMAIL_PROVIDER) { |
| 4935 | if (!currentState.emailPrefix) { |
| 4936 | throw new Error('Gmail 原邮箱未设置,请先在侧边栏填写。'); |
| 4937 | } |
| 4938 | await addLog(`=== 鐩爣 ${targetRun}/${totalRuns} 杞細Gmail +tag 妯″紡宸插惎鐢紝灏嗗湪姝ラ 3 鑷姩鐢熸垚閭锛堢 ${attemptRuns} 娆″皾璇曪級===`, 'info'); |
| 4939 | return null; |
| 4940 | } |
| 4941 | if (!currentState.emailPrefix) { |
| 4942 | throw new Error('2925 邮箱前缀未设置,请先在侧边栏填写。'); |
| 4943 | } |
| 4944 | await addLog(`=== 目标 ${targetRun}/${totalRuns} 轮:2925 模式已启用,将在步骤 3 自动生成邮箱(第 ${attemptRuns} 次尝试)===`, 'info'); |
| 4945 | return null; |
| 4946 | } |
| 4947 | |
| 4948 | if (currentState.email) { |
| 4949 | return currentState.email; |
| 4950 | } |
| 4951 | |
| 4952 | if (shouldUseCustomRegistrationEmail(currentState)) { |
| 4953 | await addLog(`=== 目标 ${targetRun}/${totalRuns} 轮已暂停:请先填写自定义注册邮箱,然后继续 ===`, 'warn'); |
| 4954 | await broadcastAutoRunStatus('waiting_email', { |
| 4955 | currentRun: targetRun, |
| 4956 | totalRuns, |
| 4957 | attemptRun: attemptRuns, |
| 4958 | }); |
| 4959 | |
| 4960 | await waitForResume(); |
| 4961 | |
| 4962 | const resumedState = await getState(); |
| 4963 | if (!resumedState.email) { |
| 4964 | throw new Error('无法继续:当前没有注册邮箱。'); |
| 4965 | } |
| 4966 | return resumedState.email; |
| 4967 | } |
| 4968 | |
| 4969 | const generator = normalizeEmailGenerator(currentState.emailGenerator); |
| 4970 | const generatorLabel = getEmailGeneratorLabel(generator); |
| 4971 | let lastError = null; |
| 4972 | for (let attempt = 1; attempt <= EMAIL_FETCH_MAX_ATTEMPTS; attempt++) { |
no test coverage detected