Merge pull request #1058 from Richards0nd/newPhoneNumberContent

Correção: Número de telefone apresentado no nome do contato (CW Service)
This commit is contained in:
Davidson Gomes 2024-11-14 18:36:43 -03:00 committed by GitHub
commit 7bf0fd1c36
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1970,11 +1970,16 @@ export class ChatwootService {
if (body.key.remoteJid.includes('@g.us')) { if (body.key.remoteJid.includes('@g.us')) {
const participantName = body.pushName; const participantName = body.pushName;
const rawPhoneNumber = body.key.remoteJid.split('@')[0]; const rawPhoneNumber = body.key.participant.split('@')[0];
const formattedPhoneNumber = `+${rawPhoneNumber.slice(0, 2)} (${rawPhoneNumber.slice( const phoneMatch = rawPhoneNumber.match(/^(\d{2})(\d{2})(\d{4})(\d{4})$/);
2,
4, let formattedPhoneNumber: string;
)}) ${rawPhoneNumber.slice(4, 8)}-${rawPhoneNumber.slice(8)}`;
if (phoneMatch) {
formattedPhoneNumber = `+${phoneMatch[1]} (${phoneMatch[2]}) ${phoneMatch[3]}-${phoneMatch[4]}`;
} else {
formattedPhoneNumber = `+${rawPhoneNumber}`;
}
let content: string; let content: string;
@ -2104,11 +2109,16 @@ export class ChatwootService {
if (body.key.remoteJid.includes('@g.us')) { if (body.key.remoteJid.includes('@g.us')) {
const participantName = body.pushName; const participantName = body.pushName;
const rawPhoneNumber = body.key.remoteJid.split('@')[0]; const rawPhoneNumber = body.key.participant.split('@')[0];
const formattedPhoneNumber = `+${rawPhoneNumber.slice(0, 2)} (${rawPhoneNumber.slice( const phoneMatch = rawPhoneNumber.match(/^(\d{2})(\d{2})(\d{4})(\d{4})$/);
2,
4, let formattedPhoneNumber: string;
)}) ${rawPhoneNumber.slice(4, 8)}-${rawPhoneNumber.slice(8)}`;
if (phoneMatch) {
formattedPhoneNumber = `+${phoneMatch[1]} (${phoneMatch[2]}) ${phoneMatch[3]}-${phoneMatch[4]}`;
} else {
formattedPhoneNumber = `+${rawPhoneNumber}`;
}
let content: string; let content: string;