fix: Adjusts to receive contact with more numbers

This commit is contained in:
Davidson Gomes 2023-07-18 14:49:38 -03:00
parent 8c7b0698f3
commit 6727b1cfca

View File

@ -1174,6 +1174,7 @@ export class ChatwootService {
const result = typeKey ? types[typeKey] : undefined; const result = typeKey ? types[typeKey] : undefined;
if (typeKey === 'contactMessage') { if (typeKey === 'contactMessage') {
console.log(result);
const vCardData = result.split('\n'); const vCardData = result.split('\n');
const contactInfo = {}; const contactInfo = {};
@ -1184,13 +1185,17 @@ export class ChatwootService {
} }
}); });
const telKey = Object.keys(contactInfo).find((key) => let formattedContact = `**Contact:**
key.startsWith('item1.TEL;waid='), **name:** ${contactInfo['FN']}`;
);
const formattedContact = `**Contact:** let numberCount = 1;
**name:** ${contactInfo['FN']} Object.keys(contactInfo).forEach((key) => {
**number:** ${contactInfo[telKey]}`; if (key.startsWith('item') && key.includes('TEL;waid=')) {
const phoneNumber = contactInfo[key];
formattedContact += `\n**number ${numberCount}:** ${phoneNumber}`;
numberCount++;
}
});
this.logger.verbose('message content: ' + formattedContact); this.logger.verbose('message content: ' + formattedContact);
return formattedContact; return formattedContact;
@ -1208,13 +1213,17 @@ export class ChatwootService {
} }
}); });
const telKey = Object.keys(contactInfo).find((key) => let formattedContact = `**Contact:**
key.startsWith('item1.TEL;waid='), **name:** ${contact.displayName}`;
);
const formattedContact = `**Contact:** let numberCount = 1;
**name:** ${contact.displayName} Object.keys(contactInfo).forEach((key) => {
**number:** ${contactInfo[telKey]}`; if (key.startsWith('item') && key.includes('TEL;waid=')) {
const phoneNumber = contactInfo[key];
formattedContact += `\n**number ${numberCount}:** ${phoneNumber}`;
numberCount++;
}
});
return formattedContact; return formattedContact;
}); });