[core] add types for toVcard
This commit is contained in:
1 parent
ef36e4d3ac
commit
c6b68cad37
1 file changed
+10
-7
+10
-7
@@ -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');
|
||||
|
||||
Reference in new issue
Block a user