fix: unify telegram thread handling

This commit is contained in:
Ayaan Zaidi
2026-02-02 08:53:42 +05:30
committed by Ayaan Zaidi
parent 5020bfa2a9
commit 19b8416a81
10 changed files with 151 additions and 46 deletions

View File

@@ -8,7 +8,7 @@ describe("createTelegramDraftStream", () => {
api: api as any,
chatId: 123,
draftId: 42,
messageThreadId: 99,
thread: { id: 99, scope: "forum" },
});
stream.update("Hello");
@@ -24,11 +24,27 @@ describe("createTelegramDraftStream", () => {
api: api as any,
chatId: 123,
draftId: 42,
messageThreadId: 1,
thread: { id: 1, scope: "forum" },
});
stream.update("Hello");
expect(api.sendMessageDraft).toHaveBeenCalledWith(123, 42, "Hello", undefined);
});
it("keeps message_thread_id for dm threads", () => {
const api = { sendMessageDraft: vi.fn().mockResolvedValue(true) };
const stream = createTelegramDraftStream({
api: api as any,
chatId: 123,
draftId: 42,
thread: { id: 1, scope: "dm" },
});
stream.update("Hello");
expect(api.sendMessageDraft).toHaveBeenCalledWith(123, 42, "Hello", {
message_thread_id: 1,
});
});
});