fix(telegram): align account inspection default routing

This commit is contained in:
Ayaan Zaidi
2026-07-01 17:29:28 -07:00
parent 85771aec05
commit 13613ecaf1
3 changed files with 41 additions and 1 deletions

View File

@@ -107,6 +107,27 @@ describe("inspectTelegramAccount SecretRef resolution", () => {
expect(account.config.reactionLevel).toBe("ack");
});
it("routes omitted-account inspection through the configured defaultAccount (#61012)", () => {
withEnv({ TELEGRAM_BOT_TOKEN: "123:env" }, () => {
const cfg: OpenClawConfig = {
channels: {
telegram: {
botToken: "123:channel",
defaultAccount: "ops",
accounts: {
ops: { botToken: "123:ops" },
},
},
},
};
const account = inspectTelegramAccount({ cfg });
expect(account.accountId).toBe("ops");
expect(account.tokenSource).toBe("config");
expect(account.token).toBe("123:ops");
});
});
it("blocks channel-token fallback for unknown scoped accounts in multi-account config", () => {
const cfg: OpenClawConfig = {
channels: {

View File

@@ -252,8 +252,9 @@ export function inspectTelegramAccount(params: {
accountId?: string | null;
envToken?: string | null;
}): InspectedTelegramAccount {
const resolvedAccountId = params.accountId ?? resolveDefaultTelegramAccountId(params.cfg);
return resolveAccountWithDefaultFallback({
accountId: params.accountId,
accountId: resolvedAccountId,
normalizeAccountId,
resolvePrimary: (accountId) =>
inspectTelegramAccountPrimary({

View File

@@ -122,6 +122,24 @@ describe("resolveTelegramReactionLevel", () => {
expectExtensiveFlags(result);
});
it("resolves omitted-account reaction level from the configured defaultAccount (#61012)", () => {
const cfg: OpenClawConfig = {
channels: {
telegram: {
botToken: "tok-default",
reactionLevel: "off",
defaultAccount: "work",
accounts: {
work: { botToken: "tok-work", reactionLevel: "extensive" },
},
},
},
};
const result = resolveTelegramReactionLevel({ cfg });
expectExtensiveFlags(result);
});
it("falls back to global level when account has no reactionLevel", () => {
const cfg: OpenClawConfig = {
channels: {