fix: honor telegram default action account

This commit is contained in:
Tak Hoffman
2026-04-03 13:48:41 -05:00
parent 88ab29f492
commit d2ca915a7f
2 changed files with 26 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ import * as runtimeEnvModule from "openclaw/plugin-sdk/runtime-env";
import { withEnv } from "openclaw/plugin-sdk/testing";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import {
createTelegramActionGate,
listTelegramAccountIds,
resolveTelegramMediaRuntimeOptions,
resetMissingDefaultWarnFlag,
@@ -333,6 +334,28 @@ describe("resolveTelegramPollActionGateState", () => {
enabled: true,
});
});
it("uses configured defaultAccount when telegram action gate accountId is omitted", () => {
const gate = createTelegramActionGate({
cfg: {
channels: {
telegram: {
actions: { sendMessage: false, poll: false },
defaultAccount: "work",
accounts: {
work: {
botToken: "123:work",
actions: { sendMessage: true, poll: true },
},
},
},
},
},
});
expect(gate("sendMessage")).toBe(true);
expect(gate("poll")).toBe(true);
});
});
describe("resolveTelegramAccount groups inheritance (#30673)", () => {

View File

@@ -156,7 +156,9 @@ export function createTelegramActionGate(params: {
cfg: OpenClawConfig;
accountId?: string | null;
}): (key: keyof TelegramActionConfig, defaultValue?: boolean) => boolean {
const accountId = normalizeAccountId(params.accountId);
const accountId = normalizeAccountId(
params.accountId ?? resolveDefaultTelegramAccountId(params.cfg),
);
return createAccountActionGate({
baseActions: params.cfg.channels?.telegram?.actions,
accountActions: resolveTelegramAccountConfig(params.cfg, accountId)?.actions,