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

Function finalizeIcloudAliasAfterSuccessfulFlow

background.js:3143–3190  ·  view source on GitHub ↗
(state)

Source from the content-addressed store, hash-verified

3141}
3142
3143async function finalizeIcloudAliasAfterSuccessfulFlow(state) {
3144 const email = String(state?.email || '').trim().toLowerCase();
3145 if (!email) {
3146 return { handled: false, deleted: false };
3147 }
3148
3149 const knownIcloudAlias = normalizeEmailGenerator(state?.emailGenerator) === 'icloud'
3150 || Object.prototype.hasOwnProperty.call(getManualAliasUsageMap(state), email)
3151 || Object.prototype.hasOwnProperty.call(getPreservedAliasMap(state), email);
3152 if (!knownIcloudAlias) {
3153 return { handled: false, deleted: false };
3154 }
3155
3156 await setIcloudAliasUsedState({ email, used: true }, { silentLog: true });
3157 await addLog(`iCloud:流程成功后已标记 ${email} 为已用。`, 'ok');
3158
3159 if (!state.autoDeleteUsedIcloudAlias) {
3160 return { handled: true, deleted: false };
3161 }
3162
3163 if (isAliasPreserved(state, email)) {
3164 await addLog(`iCloud:${email} 已被标记为保留,跳过自动删除。`, 'info');
3165 return { handled: true, deleted: false };
3166 }
3167
3168 try {
3169 const aliases = await listIcloudAliases();
3170 const alias = findIcloudAliasByEmail(aliases, email);
3171 if (!alias) {
3172 await addLog(`iCloud:自动删除跳过,列表中未找到 ${email}。`, 'warn');
3173 return { handled: true, deleted: false };
3174 }
3175 if (alias.preserved) {
3176 await addLog(`iCloud:${email} 在最新别名列表中已是保留状态,跳过自动删除。`, 'info');
3177 return { handled: true, deleted: false };
3178 }
3179 if (!alias.anonymousId) {
3180 await addLog(`iCloud:自动删除跳过,${email} 缺少 anonymousId,请先刷新列表后重试。`, 'warn');
3181 return { handled: true, deleted: false };
3182 }
3183 await deleteIcloudAlias(alias);
3184 await addLog(`iCloud:流程成功后已自动删除 ${email}。`, 'ok');
3185 return { handled: true, deleted: true };
3186 } catch (err) {
3187 await addLog(`iCloud:自动删除 ${email} 失败:${getErrorMessage(err)}`, 'warn');
3188 return { handled: true, deleted: false };
3189 }
3190}
3191
3192// ============================================================
3193// Tab Registry

Callers 2

handleStepDataFunction · 0.85
handleStepDataFunction · 0.85

Calls 10

normalizeEmailGeneratorFunction · 0.85
getManualAliasUsageMapFunction · 0.85
getPreservedAliasMapFunction · 0.85
setIcloudAliasUsedStateFunction · 0.85
isAliasPreservedFunction · 0.85
findIcloudAliasByEmailFunction · 0.85
deleteIcloudAliasFunction · 0.85
addLogFunction · 0.70
listIcloudAliasesFunction · 0.70
getErrorMessageFunction · 0.70

Tested by

no test coverage detected