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

Function upsertHotmailAccount

background.js:1300–1328  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

1298}
1299
1300async function upsertHotmailAccount(input) {
1301 const state = await getState();
1302 const accounts = normalizeHotmailAccounts(state.hotmailAccounts);
1303 const normalizedEmail = String(input?.email || '').trim().toLowerCase();
1304 const existing = input?.id
1305 ? findHotmailAccount(accounts, input.id)
1306 : accounts.find((account) => account.email.toLowerCase() === normalizedEmail) || null;
1307 const credentialsChanged = !existing
1308 || (input?.clientId !== undefined && String(input.clientId).trim() !== existing.clientId)
1309 || (input?.refreshToken !== undefined && String(input.refreshToken).trim() !== existing.refreshToken)
1310 || (input?.email !== undefined && String(input.email).trim().toLowerCase() !== existing.email.toLowerCase());
1311 const normalized = normalizeHotmailAccount({
1312 ...(existing || {}),
1313 ...(credentialsChanged ? {
1314 status: 'pending',
1315 lastAuthAt: 0,
1316 lastError: '',
1317 } : {}),
1318 ...input,
1319 id: input?.id || existing?.id || crypto.randomUUID(),
1320 });
1321
1322 const nextAccounts = existing
1323 ? accounts.map((account) => (account.id === normalized.id ? normalized : account))
1324 : [...accounts, normalized];
1325
1326 await syncHotmailAccounts(nextAccounts);
1327 return normalized;
1328}
1329
1330async function deleteHotmailAccount(accountId) {
1331 const state = await getState();

Callers 4

requestHotmailLocalCodeFunction · 0.85
handleMessageFunction · 0.85

Calls 5

getStateFunction · 0.85
normalizeHotmailAccountsFunction · 0.85
findHotmailAccountFunction · 0.85
normalizeHotmailAccountFunction · 0.85
syncHotmailAccountsFunction · 0.85

Tested by

no test coverage detected