mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-05 11:43:32 +00:00
fix(telegram): align account inspection default routing
This commit is contained in:
@@ -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: {
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user