fix(whatsapp): keep opening text chunk when first media fails on mult… · openclaw/openclaw@87854e8
yetval
·
2026-06-19
·
via Recent Commits to openclaw:main
File tree
extensions/whatsapp/src/auto-reply
| Original file line number | Diff line number | Diff line change |
|---|
@@ -624,6 +624,32 @@ describe("deliverWebReply", () => {
|
624 | 624 | expect(warnContext.mediaUrl).toBe("http://example.com/img.jpg"); |
625 | 625 | }); |
626 | 626 | |
| 627 | +it("delivers the opening text chunk when the first media fails on a multi-chunk reply", async () => { |
| 628 | +const msg = makeMsg(); |
| 629 | +mockLoadedImageMedia(); |
| 630 | +mockFirstSendMediaFailure(msg, "boom"); |
| 631 | + |
| 632 | +await deliverWebReply({ |
| 633 | +replyResult: { text: "ALPHALINEBRAVOLINE", mediaUrl: "http://example.com/img.jpg" }, |
| 634 | + msg, |
| 635 | +maxMediaBytes: 1024 * 1024, |
| 636 | +textLimit: 9, |
| 637 | + replyLogger, |
| 638 | +skipLog: true, |
| 639 | +}); |
| 640 | + |
| 641 | +expect(replyText(msg, 0)).toContain("ALPHALINE"); |
| 642 | +expect(replyText(msg, 0)).toContain("⚠️ Media failed"); |
| 643 | +const allReplies = ( |
| 644 | +msg.platform.reply as unknown as { mock: { calls: unknown[][] } } |
| 645 | +).mock.calls |
| 646 | +.map((call) => String(call[0])) |
| 647 | +.join("\n"); |
| 648 | +expect(allReplies).toContain("ALPHALINE"); |
| 649 | +expect(allReplies).toContain("BRAVOLINE"); |
| 650 | +expect(allReplies).not.toContain("boom"); |
| 651 | +}); |
| 652 | + |
627 | 653 | it("still attempts later media after the first media fails", async () => { |
628 | 654 | vi.clearAllMocks(); |
629 | 655 | const msg = makeMsg(); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -340,7 +340,7 @@ export async function deliverWebReply(params: {
|
340 | 340 | return; |
341 | 341 | } |
342 | 342 | const warning = "⚠️ Media failed."; |
343 | | -const fallbackTextParts = [remainingText.shift() ?? caption ?? "", warning].filter(Boolean); |
| 343 | +const fallbackTextParts = [caption ?? "", warning].filter(Boolean); |
344 | 344 | const fallbackText = fallbackTextParts.join("\n"); |
345 | 345 | if (!fallbackText) { |
346 | 346 | return; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。