WhatsApp: handle contact cards inbound

This commit is contained in:
Mahmoud Ibrahim
2026-01-10 01:01:51 +02:00
committed by Peter Steinberger
parent 875c62689e
commit 30b3d6ce61
2 changed files with 130 additions and 0 deletions

View File

@@ -28,6 +28,36 @@ describe("web inbound helpers", () => {
expect(body).toBe("doc");
});
it("extracts WhatsApp contact cards", () => {
const body = extractText({
contactMessage: {
displayName: "Ada Lovelace",
vcard: [
"BEGIN:VCARD",
"VERSION:3.0",
"FN:Ada Lovelace",
"TEL;TYPE=CELL:+15555550123",
"END:VCARD",
].join("\n"),
},
} as unknown as import("@whiskeysockets/baileys").proto.IMessage);
expect(body).toBe("<contact: Ada Lovelace, +15555550123>");
});
it("extracts multiple WhatsApp contact cards", () => {
const body = extractText({
contactsArrayMessage: {
contacts: [
{ displayName: "Alice" },
{ displayName: "Bob" },
{ displayName: "Charlie" },
{ displayName: "Dana" },
],
},
} as unknown as import("@whiskeysockets/baileys").proto.IMessage);
expect(body).toBe("<contacts: Alice, Bob, Charlie +1 more>");
});
it("unwraps view-once v2 extension messages", () => {
const body = extractText({
viewOnceMessageV2Extension: {