diff --git a/extensions/twitch/src/setup-surface.test.ts b/extensions/twitch/src/setup-surface.test.ts index c79af47c526..16fe106b8e2 100644 --- a/extensions/twitch/src/setup-surface.test.ts +++ b/extensions/twitch/src/setup-surface.test.ts @@ -315,6 +315,31 @@ describe("setup surface helpers", () => { }); describe("setup wizard account routing", () => { + it("reports account-scoped DM policy config keys", () => { + expect( + twitchSetupWizard.dmPolicy?.resolveConfigKeys?.( + { + channels: { + twitch: { + defaultAccount: "secondary", + }, + }, + } as Parameters< + NonNullable["resolveConfigKeys"]> + >[0], + undefined, + ), + ).toEqual({ + policyKey: "channels.twitch.accounts.secondary.allowedRoles", + allowFromKey: "channels.twitch.accounts.secondary.allowFrom", + }); + + expect(twitchSetupWizard.dmPolicy?.resolveConfigKeys?.({} as never, "alerts")).toEqual({ + policyKey: "channels.twitch.accounts.alerts.allowedRoles", + allowFromKey: "channels.twitch.accounts.alerts.allowFrom", + }); + }); + it("writes to the requested account when defaultAccount is not created yet", async () => { mockPromptText .mockReset() diff --git a/extensions/twitch/src/setup-surface.ts b/extensions/twitch/src/setup-surface.ts index d3a73408636..d49a36475b1 100644 --- a/extensions/twitch/src/setup-surface.ts +++ b/extensions/twitch/src/setup-surface.ts @@ -285,8 +285,15 @@ function setTwitchGroupPolicy( const twitchDmPolicy: ChannelSetupDmPolicy = { label: "Twitch", channel, - policyKey: "channels.twitch.allowedRoles", - allowFromKey: "channels.twitch.accounts..allowFrom", + policyKey: "channels.twitch.accounts.default.allowedRoles", + allowFromKey: "channels.twitch.accounts.default.allowFrom", + resolveConfigKeys: (cfg, accountId) => { + const resolvedAccountId = resolveSetupAccountId(cfg, accountId); + return { + policyKey: `channels.twitch.accounts.${resolvedAccountId}.allowedRoles`, + allowFromKey: `channels.twitch.accounts.${resolvedAccountId}.allowFrom`, + }; + }, getCurrent: (cfg, accountId) => { const account = getAccountConfig(cfg, resolveSetupAccountId(cfg, accountId)); if (account?.allowedRoles?.includes("all")) {