mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-27 17:11:46 +00:00
fix: honor telegram default action account
This commit is contained in:
@@ -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)", () => {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user