refactor(imessage): reuse patched setup adapter
This commit is contained in:
parent
387d9fa7c4
commit
5ddbba1c70
@ -1,8 +1,5 @@
|
|||||||
|
import { createPatchedAccountSetupAdapter } from "../../../src/channels/plugins/setup-helpers.js";
|
||||||
import {
|
import {
|
||||||
applyAccountNameToChannelSection,
|
|
||||||
DEFAULT_ACCOUNT_ID,
|
|
||||||
migrateBaseNameToDefaultAccount,
|
|
||||||
normalizeAccountId,
|
|
||||||
parseSetupEntriesAllowingWildcard,
|
parseSetupEntriesAllowingWildcard,
|
||||||
promptParsedAllowFromForScopedChannel,
|
promptParsedAllowFromForScopedChannel,
|
||||||
setChannelDmPolicyWithAllowFrom,
|
setChannelDmPolicyWithAllowFrom,
|
||||||
@ -98,62 +95,10 @@ async function promptIMessageAllowFrom(params: {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export const imessageSetupAdapter: ChannelSetupAdapter = {
|
export const imessageSetupAdapter: ChannelSetupAdapter = createPatchedAccountSetupAdapter({
|
||||||
resolveAccountId: ({ accountId }) => normalizeAccountId(accountId),
|
channelKey: channel,
|
||||||
applyAccountName: ({ cfg, accountId, name }) =>
|
buildPatch: (input) => buildIMessageSetupPatch(input),
|
||||||
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),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
type IMessageSetupWizardHandlers = {
|
type IMessageSetupWizardHandlers = {
|
||||||
resolveStatusLines: NonNullable<ChannelSetupWizard["status"]>["resolveStatusLines"];
|
resolveStatusLines: NonNullable<ChannelSetupWizard["status"]>["resolveStatusLines"];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user