mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 16:28:26 +00:00
fix(actions): layer per-account gate fallback
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user