fix(icloud): align reserve fallback logs and tests after master rebase

This commit is contained in:
daniellee2015
2026-04-26 18:37:58 +08:00
parent adf4e2d342
commit 6f8a62a092
2 changed files with 34 additions and 7 deletions
+2 -6
View File
@@ -4606,11 +4606,7 @@ async function fetchIcloudHideMyEmail(options = {}) {
await addLog(`iCloud:当前 Hide My Email 服务节点 ${new URL(serviceUrl).host}`, 'info'); await addLog(`iCloud:当前 Hide My Email 服务节点 ${new URL(serviceUrl).host}`, 'info');
let activeServiceUrl = serviceUrl; let activeServiceUrl = serviceUrl;
const { aliases: existingAliases, serviceUrl: listServiceUrl } = await loadNormalizedIcloudAliases({ const existingAliases = await listIcloudAliases();
serviceUrl: activeServiceUrl,
silent: true,
});
activeServiceUrl = listServiceUrl || activeServiceUrl;
const existingAliasEmailSet = new Set( const existingAliasEmailSet = new Set(
existingAliases existingAliases
.map((aliasItem) => String(aliasItem?.email || '').trim().toLowerCase()) .map((aliasItem) => String(aliasItem?.email || '').trim().toLowerCase())
@@ -4706,7 +4702,7 @@ async function fetchIcloudHideMyEmail(options = {}) {
throw reserveErr; throw reserveErr;
} }
await addLog(`iCloud:保留 ${generatedAlias} 失败,正在回查别名列表确认是否已成功保留...`, 'warn'); await addLog('iCloud:保留别名返回鉴权/网络异常,正在回查别名列表确认是否已创建...', 'warn');
const { aliases: aliasesAfterReserveFailure, serviceUrl: refreshedListServiceUrl } = await loadNormalizedIcloudAliases({ const { aliases: aliasesAfterReserveFailure, serviceUrl: refreshedListServiceUrl } = await loadNormalizedIcloudAliases({
serviceUrl: activeServiceUrl, serviceUrl: activeServiceUrl,
silent: true, silent: true,
+32 -1
View File
@@ -323,6 +323,18 @@ function getErrorMessage(error) {
function normalizeText(value) { function normalizeText(value) {
return String(value || '').replace(/\\s+/g, ' ').trim(); return String(value || '').replace(/\\s+/g, ' ').trim();
} }
function appendIcloudClientQueryParams(url) {
return String(url || '');
}
function isIcloudMaildomainwsHost() {
return false;
}
function shouldTryIcloudRequestPageContextFallback() {
return false;
}
async function icloudRequestViaPageContext() {
throw new Error('not expected');
}
async function fetch() { async function fetch() {
fetchCalls += 1; fetchCalls += 1;
if (fetchCalls === 1) { if (fetchCalls === 1) {
@@ -381,6 +393,18 @@ function getErrorMessage(error) {
function normalizeText(value) { function normalizeText(value) {
return String(value || '').replace(/\\s+/g, ' ').trim(); return String(value || '').replace(/\\s+/g, ' ').trim();
} }
function appendIcloudClientQueryParams(url) {
return String(url || '');
}
function isIcloudMaildomainwsHost() {
return false;
}
function shouldTryIcloudRequestPageContextFallback() {
return false;
}
async function icloudRequestViaPageContext() {
throw new Error('not expected');
}
async function fetch() { async function fetch() {
fetchCalls += 1; fetchCalls += 1;
return { return {
@@ -451,6 +475,10 @@ async function loadNormalizedIcloudAliases() {
serviceUrl: 'https://p67-maildomainws.icloud.com', serviceUrl: 'https://p67-maildomainws.icloud.com',
}; };
} }
async function listIcloudAliases() {
const response = await loadNormalizedIcloudAliases();
return response.aliases || [];
}
function pickReusableIcloudAlias() { function pickReusableIcloudAlias() {
return null; return null;
} }
@@ -477,6 +505,9 @@ function broadcastIcloudAliasesChanged(payload) {
function findIcloudAliasByEmail(aliases, email) { function findIcloudAliasByEmail(aliases, email) {
return (aliases || []).find((alias) => String(alias.email || '').toLowerCase() === String(email || '').toLowerCase()) || null; return (aliases || []).find((alias) => String(alias.email || '').toLowerCase() === String(email || '').toLowerCase()) || null;
} }
function shouldStopIcloudAutoFetchRetries() {
return true;
}
${bundle} ${bundle}
return { return {
fetchIcloudHideMyEmail, fetchIcloudHideMyEmail,
@@ -491,5 +522,5 @@ return {
assert.equal(email, 'fresh@icloud.com'); assert.equal(email, 'fresh@icloud.com');
assert.deepEqual(api.readSelectedEmails(), ['fresh@icloud.com']); assert.deepEqual(api.readSelectedEmails(), ['fresh@icloud.com']);
assert.deepEqual(api.readBroadcasts(), [{ reason: 'created', email: 'fresh@icloud.com' }]); assert.deepEqual(api.readBroadcasts(), [{ reason: 'created', email: 'fresh@icloud.com' }]);
assert.match(api.readLogs().map((entry) => entry.message).join('\n'), /按保留成功处理/); assert.match(api.readLogs().map((entry) => entry.message).join('\n'), /已在列表确认别名/);
}); });