mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-22 03:56:54 -06:00
fix: search number without 9 in number from brazil
This commit is contained in:
parent
45e03d87c7
commit
59f5208c5c
@ -380,8 +380,9 @@ export class ChatwootService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let query: any;
|
let query: any;
|
||||||
|
const isGroup = phoneNumber.includes('@g.us');
|
||||||
|
|
||||||
if (!phoneNumber.includes('@g.us')) {
|
if (!isGroup) {
|
||||||
this.logger.verbose('format phone number');
|
this.logger.verbose('format phone number');
|
||||||
query = `+${phoneNumber}`;
|
query = `+${phoneNumber}`;
|
||||||
} else {
|
} else {
|
||||||
@ -390,12 +391,21 @@ export class ChatwootService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.logger.verbose('find contact in chatwoot');
|
this.logger.verbose('find contact in chatwoot');
|
||||||
const contact: any = await client.contacts.search({
|
let contact: any = await client.contacts.search({
|
||||||
accountId: this.provider.account_id,
|
accountId: this.provider.account_id,
|
||||||
q: query,
|
q: query,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!contact) {
|
if (!contact && !isGroup && query.startsWith('+55') && query.length > 13) {
|
||||||
|
this.logger.verbose('trying without the 9th digit');
|
||||||
|
query = query.slice(0, 3) + query.slice(4);
|
||||||
|
contact = await client.contacts.search({
|
||||||
|
accountId: this.provider.account_id,
|
||||||
|
q: query,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!contact) {
|
||||||
this.logger.warn('contact not found');
|
this.logger.warn('contact not found');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user