MCPcopy Index your code
hub / github.com/QLHazyCoder/FlowPilot / pollHotmailVerificationCodeViaLocalHelper

Function pollHotmailVerificationCodeViaLocalHelper

background.js:1716–1756  ·  view source on GitHub ↗
(step, account, pollPayload = {})

Source from the content-addressed store, hash-verified

1714}
1715
1716async function pollHotmailVerificationCodeViaLocalHelper(step, account, pollPayload = {}) {
1717 const maxAttempts = Number(pollPayload.maxAttempts) || 5;
1718 const intervalMs = Number(pollPayload.intervalMs) || 3000;
1719 let workingAccount = account;
1720 let lastError = null;
1721
1722 for (let attempt = 1; attempt <= maxAttempts; attempt++) {
1723 throwIfStopped();
1724 try {
1725 await addLog(`步骤 ${step}:正在通过本地助手轮询 Hotmail 验证码(${attempt}/${maxAttempts})...`, 'info');
1726 const fetchResult = await requestHotmailLocalCode(workingAccount, pollPayload);
1727 workingAccount = fetchResult.account;
1728
1729 if (fetchResult.code) {
1730 const mailboxLabel = fetchResult.message?.mailbox || 'INBOX';
1731 if (fetchResult.usedTimeFallback) {
1732 await addLog(`步骤 ${step}:本地助手使用时间回退后命中 Hotmail ${mailboxLabel} 验证码。`, 'warn');
1733 }
1734 await addLog(`步骤 ${step}:已通过本地助手在 Hotmail ${mailboxLabel} 中找到验证码:${fetchResult.code}`, 'ok');
1735 return {
1736 ok: true,
1737 code: fetchResult.code,
1738 emailTimestamp: fetchResult.message?.receivedTimestamp || Date.now(),
1739 mailId: fetchResult.message?.id || '',
1740 };
1741 }
1742
1743 lastError = new Error(`步骤 ${step}:本地助手暂未返回匹配验证码(${attempt}/${maxAttempts})。`);
1744 await addLog(lastError.message, attempt === maxAttempts ? 'warn' : 'info');
1745 } catch (err) {
1746 lastError = err;
1747 await addLog(`步骤 ${step}:本地助手轮询 Hotmail 失败:${err.message}`, 'warn');
1748 }
1749
1750 if (attempt < maxAttempts) {
1751 await sleepWithStop(intervalMs);
1752 }
1753 }
1754
1755 throw lastError || new Error(`步骤 ${step}:本地助手未返回新的匹配验证码。`);
1756}
1757
1758async function fetchHotmailMailboxMessages(account, mailboxes = HOTMAIL_MAILBOXES) {
1759 const serviceSettings = getHotmailServiceSettings(await getState());

Callers 1

Calls 4

requestHotmailLocalCodeFunction · 0.85
sleepWithStopFunction · 0.85
throwIfStoppedFunction · 0.70
addLogFunction · 0.70

Tested by

no test coverage detected