diff --git a/extensions/bluebubbles/src/actions.ts b/extensions/bluebubbles/src/actions.ts index c96dd526d56..adccf32b6c4 100644 --- a/extensions/bluebubbles/src/actions.ts +++ b/extensions/bluebubbles/src/actions.ts @@ -77,7 +77,7 @@ export const bluebubblesMessageActions: ChannelMessageActionAdapter = { if (!account.enabled || !account.configured) { return null; } - const gate = createActionGate(account.config.actions); + const gate = createActionGate(cfg.channels?.bluebubbles?.actions); const actions = new Set(); const macOS26 = isMacOS26OrHigher(account.accountId); const privateApiStatus = getCachedBlueBubblesPrivateApiStatus(account.accountId); diff --git a/extensions/feishu/src/setup-surface.ts b/extensions/feishu/src/setup-surface.ts index c3ade69a996..f121dd4d33e 100644 --- a/extensions/feishu/src/setup-surface.ts +++ b/extensions/feishu/src/setup-surface.ts @@ -4,7 +4,6 @@ import { formatDocsLink, hasConfiguredSecretInput, mergeAllowFromEntries, - patchChannelConfigForAccount, patchTopLevelChannelConfigSection, promptSingleChannelSecretInput, splitSetupEntries, @@ -33,11 +32,10 @@ function normalizeString(value: unknown): string | undefined { return trimmed || undefined; } -function getScopedFeishuConfig( - cfg: OpenClawConfig, - accountId: string, -): FeishuConfig | FeishuAccountConfig { - const feishuCfg = ((cfg.channels?.feishu as FeishuConfig | undefined) ?? {}) as FeishuConfig; +type ScopedFeishuConfig = Partial & Partial; + +function getScopedFeishuConfig(cfg: OpenClawConfig, accountId: string): ScopedFeishuConfig { + const feishuCfg = cfg.channels?.feishu as FeishuConfig | undefined; if (accountId === DEFAULT_ACCOUNT_ID) { return feishuCfg; } @@ -49,11 +47,30 @@ function patchFeishuConfig( accountId: string, patch: Record, ): OpenClawConfig { - return patchChannelConfigForAccount({ + const feishuCfg = cfg.channels?.feishu as FeishuConfig | undefined; + if (accountId === DEFAULT_ACCOUNT_ID) { + return patchTopLevelChannelConfigSection({ + cfg, + channel, + enabled: true, + patch, + }); + } + const nextAccountPatch = { + ...((feishuCfg?.accounts?.[accountId] as Record | undefined) ?? {}), + enabled: true, + ...patch, + }; + return patchTopLevelChannelConfigSection({ cfg, channel, - accountId, - patch, + enabled: true, + patch: { + accounts: { + ...(feishuCfg?.accounts ?? {}), + [accountId]: nextAccountPatch, + }, + }, }); } diff --git a/src/gateway/server-methods/config.test-helpers.ts b/src/gateway/server-methods/config.test-helpers.ts index 3916d939173..9b151c85d95 100644 --- a/src/gateway/server-methods/config.test-helpers.ts +++ b/src/gateway/server-methods/config.test-helpers.ts @@ -1,8 +1,22 @@ -import { vi } from "vitest"; +import { vi, type Mock } from "vitest"; import type { OpenClawConfig } from "../../config/types.openclaw.js"; import type { GatewayRequestHandlerOptions } from "./types.js"; -function createGatewayLog() { +type UnknownMock = Mock<(...args: unknown[]) => unknown>; +type GatewayLogMocks = { + error: UnknownMock; + warn: UnknownMock; + info: UnknownMock; + debug: UnknownMock; +}; +type ConfigHandlerHarness = { + options: GatewayRequestHandlerOptions; + respond: UnknownMock; + logGateway: GatewayLogMocks; + disconnectClientsUsingSharedGatewayAuth: UnknownMock; +}; + +function createGatewayLog(): GatewayLogMocks { return { error: vi.fn(), warn: vi.fn(), @@ -37,7 +51,7 @@ export function createConfigHandlerHarness(args?: { params?: unknown; overrides?: Partial; contextOverrides?: Partial; -}) { +}): ConfigHandlerHarness { const logGateway = createGatewayLog(); const disconnectClientsUsingSharedGatewayAuth = vi.fn(); const respond = vi.fn();