From 103dd3af64badb637547b3c4cfb852dfd7839b5b Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 10 Jan 2026 01:02:28 +0100 Subject: [PATCH] fix: keep contact summary counts (#625) (thanks @mahmoudashraf93) --- src/web/inbound.test.ts | 24 +++++++++++++++++++++++- src/web/inbound.ts | 5 ++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/web/inbound.test.ts b/src/web/inbound.test.ts index de9fd4a13..1a31303cd 100644 --- a/src/web/inbound.test.ts +++ b/src/web/inbound.test.ts @@ -124,10 +124,32 @@ describe("web inbound helpers", () => { }, } as unknown as import("@whiskeysockets/baileys").proto.IMessage); expect(body).toBe( - "", + "", ); }); + it("counts empty WhatsApp contact cards in array summaries", () => { + const body = extractText({ + contactsArrayMessage: { + contacts: [ + { + displayName: "Alice", + vcard: [ + "BEGIN:VCARD", + "VERSION:3.0", + "FN:Alice", + "TEL;TYPE=CELL:+15555550101", + "END:VCARD", + ].join("\n"), + }, + {}, + {}, + ], + }, + } as unknown as import("@whiskeysockets/baileys").proto.IMessage); + expect(body).toBe(""); + }); + it("summarizes empty WhatsApp contact cards with a count", () => { const body = extractText({ contactsArrayMessage: { diff --git a/src/web/inbound.ts b/src/web/inbound.ts index 38f43b3fe..8fc094515 100644 --- a/src/web/inbound.ts +++ b/src/web/inbound.ts @@ -801,7 +801,10 @@ function formatContactsPlaceholder(labels: string[], total: number): string { const suffix = total === 1 ? "contact" : "contacts"; return ``; } - return ``; + const shown = cleaned.slice(0, 3); + const remaining = Math.max(total - shown.length, 0); + const suffix = remaining > 0 ? ` +${remaining} more` : ""; + return ``; } function formatContactLabel(