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');