mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-26 18:38:39 -06:00
fix baileys contact update and insert
This commit is contained in:
parent
2c76098d59
commit
98efc10b11
@ -867,7 +867,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
|
|
||||||
'contacts.update': async (contacts: Partial<Contact>[], database: Database) => {
|
'contacts.update': async (contacts: Partial<Contact>[], database: Database) => {
|
||||||
this.logger.verbose('Event received: contacts.update');
|
this.logger.verbose('Event received: contacts.update');
|
||||||
|
|
||||||
this.logger.verbose('Verifying if contacts exists in database to update');
|
this.logger.verbose('Verifying if contacts exists in database to update');
|
||||||
const contactsRaw: ContactRaw[] = [];
|
const contactsRaw: ContactRaw[] = [];
|
||||||
for await (const contact of contacts) {
|
for await (const contact of contacts) {
|
||||||
@ -882,8 +881,9 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
this.logger.verbose('Sending data to webhook in event CONTACTS_UPDATE');
|
this.logger.verbose('Sending data to webhook in event CONTACTS_UPDATE');
|
||||||
this.sendDataWebhook(Events.CONTACTS_UPDATE, contactsRaw);
|
this.sendDataWebhook(Events.CONTACTS_UPDATE, contactsRaw);
|
||||||
|
|
||||||
|
//REMOVING DUE TO CREATING NULL CONTACTS ( ADDING FILTER )
|
||||||
this.logger.verbose('Updating contacts in database');
|
this.logger.verbose('Updating contacts in database');
|
||||||
this.repository.contact.update(contactsRaw, this.instance.name, database.SAVE_DATA.CONTACTS);
|
this.repository.contact.update(contactsRaw.filter(contact => contact.pushName), this.instance.name, database.SAVE_DATA.CONTACTS);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1255,10 +1255,10 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
|
|
||||||
this.logger.verbose('Inserting contact in database');
|
this.logger.verbose('Inserting contact in database');
|
||||||
|
|
||||||
if (received?.key?.fromMe === true) {
|
if (received?.key?.fromMe === true)
|
||||||
contactRaw.pushName = null;
|
contactRaw.pushName = null;
|
||||||
}
|
if (contactRaw.pushName)
|
||||||
this.repository.contact.insert([contactRaw], this.instance.name, database.SAVE_DATA.CONTACTS);
|
this.repository.contact.insert([contactRaw], this.instance.name, database.SAVE_DATA.CONTACTS);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error(error);
|
this.logger.error(error);
|
||||||
|
Loading…
Reference in New Issue
Block a user