refactor(imessage): reuse patched setup adapter

This commit is contained in:
Peter Steinberger 2026-03-17 03:47:42 +00:00
parent 387d9fa7c4
commit 5ddbba1c70
1 changed files with 5 additions and 60 deletions

View File

@ -1,8 +1,5 @@
import { createPatchedAccountSetupAdapter } from "../../../src/channels/plugins/setup-helpers.js";
import {
applyAccountNameToChannelSection,
DEFAULT_ACCOUNT_ID,
migrateBaseNameToDefaultAccount,
normalizeAccountId,
parseSetupEntriesAllowingWildcard,
promptParsedAllowFromForScopedChannel,
setChannelDmPolicyWithAllowFrom,
@ -98,62 +95,10 @@ async function promptIMessageAllowFrom(params: {
});
}
export const imessageSetupAdapter: ChannelSetupAdapter = {
resolveAccountId: ({ accountId }) => normalizeAccountId(accountId),
applyAccountName: ({ cfg, accountId, name }) =>
applyAccountNameToChannelSection({
cfg,
channelKey: channel,
accountId,
name,
}),
applyAccountConfig: ({ cfg, accountId, input }) => {
const namedConfig = applyAccountNameToChannelSection({
cfg,
channelKey: channel,
accountId,
name: input.name,
});
const next =
accountId !== DEFAULT_ACCOUNT_ID
? migrateBaseNameToDefaultAccount({
cfg: namedConfig,
channelKey: channel,
})
: namedConfig;
if (accountId === DEFAULT_ACCOUNT_ID) {
return {
...next,
channels: {
...next.channels,
imessage: {
...next.channels?.imessage,
enabled: true,
...buildIMessageSetupPatch(input),
},
},
};
}
return {
...next,
channels: {
...next.channels,
imessage: {
...next.channels?.imessage,
enabled: true,
accounts: {
...next.channels?.imessage?.accounts,
[accountId]: {
...next.channels?.imessage?.accounts?.[accountId],
enabled: true,
...buildIMessageSetupPatch(input),
},
},
},
},
};
},
};
export const imessageSetupAdapter: ChannelSetupAdapter = createPatchedAccountSetupAdapter({
channelKey: channel,
buildPatch: (input) => buildIMessageSetupPatch(input),
});
type IMessageSetupWizardHandlers = {
resolveStatusLines: NonNullable<ChannelSetupWizard["status"]>["resolveStatusLines"];