From 5ddbba1c70c86da87ee3bd01bbff4af0c8ee4ddc Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 17 Mar 2026 03:47:42 +0000 Subject: [PATCH] refactor(imessage): reuse patched setup adapter --- extensions/imessage/src/setup-core.ts | 65 +++------------------------ 1 file changed, 5 insertions(+), 60 deletions(-) diff --git a/extensions/imessage/src/setup-core.ts b/extensions/imessage/src/setup-core.ts index 4304a482ad6..45f385e0691 100644 --- a/extensions/imessage/src/setup-core.ts +++ b/extensions/imessage/src/setup-core.ts @@ -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["resolveStatusLines"];