mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-12 19:39:36 -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;
|
return contact;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (
|
if ((error.status === 422 || error.response?.status === 422) && jid) {
|
||||||
(error.status === 422 || error.response?.status === 422) &&
|
this.logger.warn(`Contact with identifier ${jid} creation failed (422). Checking if it already exists...`);
|
||||||
(error.message?.includes('taken') || error.response?.data?.message?.includes('taken')) &&
|
|
||||||
jid
|
|
||||||
) {
|
|
||||||
this.logger.warn(`Contact with identifier ${jid} already exists, trying to find it...`);
|
|
||||||
const existingContact = await this.findContactByIdentifier(instance, jid);
|
const existingContact = await this.findContactByIdentifier(instance, jid);
|
||||||
if (existingContact) {
|
if (existingContact) {
|
||||||
const contactId = existingContact.id;
|
const contactId = existingContact.id;
|
||||||
@ -2535,7 +2531,7 @@ export class ChatwootService {
|
|||||||
if (!remoteJid) {
|
if (!remoteJid) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
return remoteJid.replace(/:\d+/, '').replace('@s.whatsapp.net', '').replace('@g.us', '').replace('@lid', '');
|
return remoteJid.replace(/:\d+/, '').split('@')[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public startImportHistoryMessages(instance: InstanceDto) {
|
public startImportHistoryMessages(instance: InstanceDto) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user