mirror of
https://github.com/Elysola/WebHooker.git
synced 2026-11-21 01:23:40 +00:00
fix(telegram): keep editable messages as text
Guessing photo versus text from message content makes later edits use the wrong API and a smaller caption budget. Always send text and use the avatar as a link preview.
This commit is contained in:
1 parent
867d2af6ac
commit
dd45e13cb1
2 files changed
+37
-24
No files matched your search
+12
-3
@@ -224,9 +224,11 @@ describe("TelegramDriver", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("sends a small avatar photo (s=64) when the author has an icon", async () => {
|
||||
it("shows a small avatar (s=64) as the link preview of a text message", async () => {
|
||||
let capturedInit: RequestInit | undefined;
|
||||
let capturedUrl = "";
|
||||
mockFetch((url, init) => {
|
||||
capturedUrl = url;
|
||||
capturedInit = init;
|
||||
return new Response(JSON.stringify({ ok: true, result: { message_id: 9 } }), { status: 200 });
|
||||
});
|
||||
@@ -242,8 +244,15 @@ describe("TelegramDriver", () => {
|
||||
);
|
||||
|
||||
expect(result.ok).toBe(true);
|
||||
const body = JSON.parse(String(capturedInit!.body)) as Record<string, unknown>;
|
||||
expect(body.photo).toBe("https://avatars.githubusercontent.com/u/1?v=4&s=64");
|
||||
// A text message (never a captioned photo), so later edits keep the full
|
||||
// 4096-character budget.
|
||||
expect(capturedUrl).toContain("/sendMessage");
|
||||
const body = JSON.parse(String(capturedInit!.body)) as {
|
||||
link_preview_options?: { url?: string };
|
||||
};
|
||||
expect(body.link_preview_options?.url).toBe(
|
||||
"https://avatars.githubusercontent.com/u/1?v=4&s=64",
|
||||
);
|
||||
});
|
||||
|
||||
it("sends a plain message when the author has no icon", async () => {
|
||||
|
||||
Reference in new issue
Block a user