mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 12:31:23 +00:00
fix: tighten thread-clear and telegram retry guards
This commit is contained in:
@@ -508,6 +508,23 @@ describe("sendMessageTelegram", () => {
|
||||
expect(res.messageId).toBe("58");
|
||||
});
|
||||
|
||||
it("does not retry thread-not-found when no message_thread_id was provided", async () => {
|
||||
const chatId = "123";
|
||||
const threadErr = new Error("400: Bad Request: message thread not found");
|
||||
const sendMessage = vi.fn().mockRejectedValueOnce(threadErr);
|
||||
const api = { sendMessage } as unknown as {
|
||||
sendMessage: typeof sendMessage;
|
||||
};
|
||||
|
||||
await expect(
|
||||
sendMessageTelegram(chatId, "hello forum", {
|
||||
token: "tok",
|
||||
api,
|
||||
}),
|
||||
).rejects.toThrow("message thread not found");
|
||||
expect(sendMessage).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("sets disable_notification when silent is true", async () => {
|
||||
const chatId = "123";
|
||||
const sendMessage = vi.fn().mockResolvedValue({
|
||||
|
||||
@@ -179,7 +179,17 @@ function isTelegramThreadNotFoundError(err: unknown): boolean {
|
||||
}
|
||||
|
||||
function hasMessageThreadIdParam(params?: Record<string, unknown>): boolean {
|
||||
return Boolean(params && Object.hasOwn(params, "message_thread_id"));
|
||||
if (!params) {
|
||||
return false;
|
||||
}
|
||||
const value = params.message_thread_id;
|
||||
if (typeof value === "number") {
|
||||
return Number.isFinite(value);
|
||||
}
|
||||
if (typeof value === "string") {
|
||||
return value.trim().length > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function removeMessageThreadIdParam(
|
||||
|
||||
Reference in New Issue
Block a user