Skip to content

Commit b7da8d2

Browse files
committed
added email in vcard
1 parent 41f1919 commit b7da8d2

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/validate/validate.schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ export const contactMessageSchema: JSONSchema7 = {
380380
},
381381
phoneNumber: { type: 'string', minLength: 10 },
382382
organization: { type: 'string' },
383+
email: { type: 'string' },
383384
},
384385
required: ['fullName', 'wuid', 'phoneNumber'],
385386
...isNotEmpty('fullName'),

src/whatsapp/dto/sendMessage.dto.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export class ContactMessage {
126126
wuid: string;
127127
phoneNumber: string;
128128
organization?: string;
129+
email?: string;
129130
}
130131
export class SendContactDto extends Metadata {
131132
contactMessage: ContactMessage[];

src/whatsapp/services/whatsapp.service.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,16 +1425,26 @@ export class WAStartupService {
14251425
const message: proto.IMessage = {};
14261426

14271427
const vcard = (contact: ContactMessage) => {
1428-
return (
1428+
let result =
14291429
'BEGIN:VCARD\n' +
14301430
'VERSION:3.0\n' +
14311431
`N:${contact.fullName}\n` +
1432-
`FN:${contact.fullName}\n` +
1433-
`ORG:${contact.organization};\n` +
1432+
`FN:${contact.fullName}\n`;
1433+
1434+
if (contact.organization) {
1435+
result += `ORG:${contact.organization};\n`;
1436+
}
1437+
1438+
if (contact.email) {
1439+
result += `EMAIL:${contact.email}\n`;
1440+
}
1441+
1442+
result +=
14341443
`item1.TEL;waid=${contact.wuid}:${contact.phoneNumber}\n` +
14351444
'item1.X-ABLabel:Celular\n' +
1436-
'END:VCARD'
1437-
);
1445+
'END:VCARD';
1446+
1447+
return result;
14381448
};
14391449

14401450
if (data.contactMessage.length === 1) {

0 commit comments

Comments
 (0)