mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 08:41:23 +00:00
fix(actions): layer per-account gate fallback
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { createAccountListHelpers } from "../channels/plugins/account-helpers.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import type { DiscordAccountConfig } from "../config/types.js";
|
||||
import type { DiscordAccountConfig, DiscordActionConfig } from "../config/types.js";
|
||||
import { createAccountListHelpers } from "../channels/plugins/account-helpers.js";
|
||||
import { normalizeAccountId } from "../routing/session-key.js";
|
||||
import { resolveDiscordToken } from "./token.js";
|
||||
|
||||
@@ -36,6 +36,26 @@ function mergeDiscordAccountConfig(cfg: OpenClawConfig, accountId: string): Disc
|
||||
return { ...base, ...account };
|
||||
}
|
||||
|
||||
export function createDiscordActionGate(params: {
|
||||
cfg: OpenClawConfig;
|
||||
accountId?: string | null;
|
||||
}): (key: keyof DiscordActionConfig, defaultValue?: boolean) => boolean {
|
||||
const accountId = normalizeAccountId(params.accountId);
|
||||
const baseActions = params.cfg.channels?.discord?.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 resolveDiscordAccount(params: {
|
||||
cfg: OpenClawConfig;
|
||||
accountId?: string | null;
|
||||
|
||||
Reference in New Issue
Block a user