mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-09 01:49:37 -06:00
fix: improve error handling for existing contacts and simplify remoteJid processing
This commit is contained in:
parent
baff4e8f5e
commit
faed3f4574
@ -346,12 +346,8 @@ export class ChatwootService {
|
||||
|
||||
return contact;
|
||||
} catch (error) {
|
||||
if (
|
||||
(error.status === 422 || error.response?.status === 422) &&
|
||||
(error.message?.includes('taken') || error.response?.data?.message?.includes('taken')) &&
|
||||
jid
|
||||
) {
|
||||
this.logger.warn(`Contact with identifier ${jid} already exists, trying to find it...`);
|
||||
if ((error.status === 422 || error.response?.status === 422) && jid) {
|
||||
this.logger.warn(`Contact with identifier ${jid} creation failed (422). Checking if it already exists...`);
|
||||
const existingContact = await this.findContactByIdentifier(instance, jid);
|
||||
if (existingContact) {
|
||||
const contactId = existingContact.id;
|
||||
@ -2535,7 +2531,7 @@ export class ChatwootService {
|
||||
if (!remoteJid) {
|
||||
return '';
|
||||
}
|
||||
return remoteJid.replace(/:\d+/, '').replace('@s.whatsapp.net', '').replace('@g.us', '').replace('@lid', '');
|
||||
return remoteJid.replace(/:\d+/, '').split('@')[0];
|
||||
}
|
||||
|
||||
public startImportHistoryMessages(instance: InstanceDto) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user