added email in vcard

This commit is contained in:
Davidson Gomes 2023-07-05 21:14:44 -03:00
parent 41f191902b
commit b7da8d2193
3 changed files with 17 additions and 5 deletions

View File

@ -380,6 +380,7 @@ export const contactMessageSchema: JSONSchema7 = {
}, },
phoneNumber: { type: 'string', minLength: 10 }, phoneNumber: { type: 'string', minLength: 10 },
organization: { type: 'string' }, organization: { type: 'string' },
email: { type: 'string' },
}, },
required: ['fullName', 'wuid', 'phoneNumber'], required: ['fullName', 'wuid', 'phoneNumber'],
...isNotEmpty('fullName'), ...isNotEmpty('fullName'),

View File

@ -126,6 +126,7 @@ export class ContactMessage {
wuid: string; wuid: string;
phoneNumber: string; phoneNumber: string;
organization?: string; organization?: string;
email?: string;
} }
export class SendContactDto extends Metadata { export class SendContactDto extends Metadata {
contactMessage: ContactMessage[]; contactMessage: ContactMessage[];

View File

@ -1425,16 +1425,26 @@ export class WAStartupService {
const message: proto.IMessage = {}; const message: proto.IMessage = {};
const vcard = (contact: ContactMessage) => { const vcard = (contact: ContactMessage) => {
return ( let result =
'BEGIN:VCARD\n' + 'BEGIN:VCARD\n' +
'VERSION:3.0\n' + 'VERSION:3.0\n' +
`N:${contact.fullName}\n` + `N:${contact.fullName}\n` +
`FN:${contact.fullName}\n` + `FN:${contact.fullName}\n`;
`ORG:${contact.organization};\n` +
if (contact.organization) {
result += `ORG:${contact.organization};\n`;
}
if (contact.email) {
result += `EMAIL:${contact.email}\n`;
}
result +=
`item1.TEL;waid=${contact.wuid}:${contact.phoneNumber}\n` + `item1.TEL;waid=${contact.wuid}:${contact.phoneNumber}\n` +
'item1.X-ABLabel:Celular\n' + 'item1.X-ABLabel:Celular\n' +
'END:VCARD' 'END:VCARD';
);
return result;
}; };
if (data.contactMessage.length === 1) { if (data.contactMessage.length === 1) {