fix: use per-account action config for Discord and Telegram gating

listActions now unions gates across all enabled accounts (matching the
Signal pattern), and handleDiscordAction/handleTelegramAction resolve
through the per-account merged config instead of reading only the
top-level channel actions object.  This lets account-specific
moderation/sticker/presence overrides take effect at both listing and
execution time.
This commit is contained in:
El-Fitz
2026-02-16 14:22:52 +01:00
committed by Peter Steinberger
parent 1faf8e8e9d
commit a03fec2a3f
4 changed files with 17 additions and 4 deletions

View File

@@ -1,3 +1,4 @@
import type { DiscordActionConfig } from "../../../config/types.discord.js";
import type { ChannelMessageActionAdapter, ChannelMessageActionName } from "../types.js";
import { createActionGate } from "../../../agents/tools/common.js";
import { listEnabledDiscordAccounts } from "../../../discord/accounts.js";
@@ -11,7 +12,10 @@ export const discordMessageActions: ChannelMessageActionAdapter = {
if (accounts.length === 0) {
return [];
}
const gate = createActionGate(cfg.channels?.discord?.actions);
// Union of all accounts' action gates (any account enabling an action makes it available)
const gates = accounts.map((a) => createActionGate(a.config.actions));
const gate = (key: keyof DiscordActionConfig, defaultValue = true) =>
gates.some((g) => g(key, defaultValue));
const actions = new Set<ChannelMessageActionName>(["send"]);
if (gate("polls")) {
actions.add("poll");

View File

@@ -1,3 +1,4 @@
import type { TelegramActionConfig } from "../../../config/types.telegram.js";
import type { ChannelMessageActionAdapter, ChannelMessageActionName } from "../types.js";
import {
createActionGate,
@@ -46,7 +47,10 @@ export const telegramMessageActions: ChannelMessageActionAdapter = {
if (accounts.length === 0) {
return [];
}
const gate = createActionGate(cfg.channels?.telegram?.actions);
// Union of all accounts' action gates (any account enabling an action makes it available)
const gates = accounts.map((a) => createActionGate(a.config.actions));
const gate = (key: keyof TelegramActionConfig, defaultValue = true) =>
gates.some((g) => g(key, defaultValue));
const actions = new Set<ChannelMessageActionName>(["send"]);
if (gate("reactions")) {
actions.add("react");