From c6b68cad3738b165d50c0fe2357b28af9cac9ebf Mon Sep 17 00:00:00 2001 From: devlikepro Date: Sun, 18 May 2025 11:07:39 +0700 Subject: [PATCH] [core] add types for toVcard --- src/core/helpers.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/core/helpers.ts b/src/core/helpers.ts index fd886435..d8b70f63 100644 --- a/src/core/helpers.ts +++ b/src/core/helpers.ts @@ -1,20 +1,23 @@ -export function toVcard(data): string { +import { Contact, VCardContact } from '@waha/structures/chatting.dto'; + +export function toVcard(data: Contact | VCardContact): string { if (data.vcard) { return data.vcard; } + const contact: Contact = data as any; const parts = []; parts.push('BEGIN:VCARD'); parts.push('VERSION:3.0'); - parts.push(`FN:${data.fullName}`); - if (data.organization) { - parts.push(`ORG:${data.organization};`); + parts.push(`FN:${contact.fullName}`); + if (contact.organization) { + parts.push(`ORG:${contact.organization};`); } - if (data.whatsappId) { + if (contact.whatsappId) { parts.push( - `TEL;type=CELL;type=VOICE;waid=${data.whatsappId}:${data.phoneNumber}`, + `TEL;type=CELL;type=VOICE;waid=${contact.whatsappId}:${contact.phoneNumber}`, ); } else { - parts.push(`TEL;type=CELL;type=VOICE:${data.phoneNumber}`); + parts.push(`TEL;type=CELL;type=VOICE:${contact.phoneNumber}`); } parts.push('END:VCARD'); return parts.join('\n');