fix(actions): layer per-account gate fallback

This commit is contained in:
Sebastian
2026-02-16 20:59:23 -05:00
parent 616c0bd4c7
commit 2b3ecee7c5
10 changed files with 203 additions and 25 deletions

View File

@@ -1,5 +1,5 @@
import type { OpenClawConfig } from "../config/config.js";
import type { TelegramAccountConfig } from "../config/types.js";
import type { TelegramAccountConfig, TelegramActionConfig } from "../config/types.js";
import { isTruthyEnvValue } from "../infra/env.js";
import { listBoundAccountIds, resolveDefaultAgentBoundAccountId } from "../routing/bindings.js";
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../routing/session-key.js";
@@ -82,6 +82,26 @@ function mergeTelegramAccountConfig(cfg: OpenClawConfig, accountId: string): Tel
return { ...base, ...account };
}
export function createTelegramActionGate(params: {
cfg: OpenClawConfig;
accountId?: string | null;
}): (key: keyof TelegramActionConfig, defaultValue?: boolean) => boolean {
const accountId = normalizeAccountId(params.accountId);
const baseActions = params.cfg.channels?.telegram?.actions;
const accountActions = resolveAccountConfig(params.cfg, accountId)?.actions;
return (key, defaultValue = true) => {
const accountValue = accountActions?.[key];
if (accountValue !== undefined) {
return accountValue;
}
const baseValue = baseActions?.[key];
if (baseValue !== undefined) {
return baseValue;
}
return defaultValue;
};
}
export function resolveTelegramAccount(params: {
cfg: OpenClawConfig;
accountId?: string | null;