mirror of https://github.com/openclaw/openclaw.git
fix: honor telegram default debounce account
This commit is contained in:
parent
a715b83e67
commit
f7f467b042
|
|
@ -0,0 +1,9 @@
|
|||
export function buildTelegramInboundDebounceKey(params: {
|
||||
accountId?: string | null;
|
||||
conversationKey: string;
|
||||
senderId: string;
|
||||
debounceLane: "default" | "forward";
|
||||
}): string {
|
||||
const resolvedAccountId = params.accountId?.trim() || "default";
|
||||
return `telegram:${resolvedAccountId}:${params.conversationKey}:${params.senderId}:${params.debounceLane}`;
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { buildTelegramInboundDebounceKey } from "./bot-handlers.debounce-key.js";
|
||||
|
||||
describe("buildTelegramInboundDebounceKey", () => {
|
||||
it("uses the resolved account id instead of literal default when provided", () => {
|
||||
expect(
|
||||
buildTelegramInboundDebounceKey({
|
||||
accountId: "work",
|
||||
conversationKey: "12345",
|
||||
senderId: "67890",
|
||||
debounceLane: "default",
|
||||
}),
|
||||
).toBe("telegram:work:12345:67890:default");
|
||||
});
|
||||
|
||||
it("falls back to literal default only when account id is actually absent", () => {
|
||||
expect(
|
||||
buildTelegramInboundDebounceKey({
|
||||
accountId: undefined,
|
||||
conversationKey: "12345",
|
||||
senderId: "67890",
|
||||
debounceLane: "forward",
|
||||
}),
|
||||
).toBe("telegram:default:12345:67890:forward");
|
||||
});
|
||||
});
|
||||
|
|
@ -101,6 +101,7 @@ import {
|
|||
resolveModelSelection,
|
||||
type ProviderInfo,
|
||||
} from "./model-buttons.js";
|
||||
import { buildTelegramInboundDebounceKey } from "./bot-handlers.debounce-key.js";
|
||||
import { buildInlineKeyboard } from "./send.js";
|
||||
|
||||
export const registerTelegramHandlers = ({
|
||||
|
|
@ -1085,7 +1086,12 @@ export const registerTelegramHandlers = ({
|
|||
conversationThreadId != null ? `${chatId}:topic:${conversationThreadId}` : String(chatId);
|
||||
const debounceLane = resolveTelegramDebounceLane(msg);
|
||||
const debounceKey = senderId
|
||||
? `telegram:${accountId ?? "default"}:${conversationKey}:${senderId}:${debounceLane}`
|
||||
? buildTelegramInboundDebounceKey({
|
||||
accountId,
|
||||
conversationKey,
|
||||
senderId,
|
||||
debounceLane,
|
||||
})
|
||||
: null;
|
||||
await inboundDebouncer.enqueue({
|
||||
ctx,
|
||||
|
|
|
|||
Loading…
Reference in New Issue