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

Function ensureHotmailAccountForFlow

background.js:1419–1447  ·  view source on GitHub ↗
(options = {})

Source from the content-addressed store, hash-verified

1417}
1418
1419async function ensureHotmailAccountForFlow(options = {}) {
1420 const { allowAllocate = true, markUsed = false, preferredAccountId = null } = options;
1421 const state = await getState();
1422 const accounts = normalizeHotmailAccounts(state.hotmailAccounts);
1423 const isAccountAllocatable = (candidate) => Boolean(candidate)
1424 && candidate.status === 'authorized'
1425 && !candidate.used
1426 && Boolean(candidate.refreshToken);
1427
1428 let account = null;
1429 if (preferredAccountId) {
1430 account = findHotmailAccount(accounts, preferredAccountId);
1431 }
1432 if (!account && state.currentHotmailAccountId) {
1433 account = findHotmailAccount(accounts, state.currentHotmailAccountId);
1434 }
1435 if ((!account || !isAccountAllocatable(account)) && allowAllocate) {
1436 account = pickHotmailAccountForRun(accounts, {});
1437 }
1438
1439 if (!account) {
1440 throw new Error('没有可用的 Hotmail 账号。请先在侧边栏添加至少一个带刷新令牌(refresh token)的账号。');
1441 }
1442 if (!isAccountAllocatable(account)) {
1443 throw new Error(`Hotmail 账号 ${account.email || account.id} 尚未就绪,无法读取邮件。`);
1444 }
1445
1446 return setCurrentHotmailAccount(account.id, { markUsed, syncEmail: true });
1447}
1448
1449function buildHotmailLocalEndpoint(baseUrl, path) {
1450 const normalizedBaseUrl = normalizeHotmailLocalBaseUrl(baseUrl);

Callers 3

ensureAutoEmailReadyFunction · 0.85

Calls 6

getStateFunction · 0.85
normalizeHotmailAccountsFunction · 0.85
findHotmailAccountFunction · 0.85
isAccountAllocatableFunction · 0.85
pickHotmailAccountForRunFunction · 0.85
setCurrentHotmailAccountFunction · 0.85

Tested by

no test coverage detected