refactor(channels): share account action gate resolution
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { createAccountActionGate } from "../channels/plugins/account-action-gate.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import type { TelegramAccountConfig, TelegramActionConfig } from "../config/types.js";
|
||||
import { isTruthyEnvValue } from "../infra/env.js";
|
||||
@@ -87,19 +88,10 @@ export function createTelegramActionGate(params: {
|
||||
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;
|
||||
};
|
||||
return createAccountActionGate({
|
||||
baseActions: params.cfg.channels?.telegram?.actions,
|
||||
accountActions: resolveAccountConfig(params.cfg, accountId)?.actions,
|
||||
});
|
||||
}
|
||||
|
||||
export function resolveTelegramAccount(params: {
|
||||
|
||||
Reference in New Issue
Block a user