fix bailys naiming of contacts

This commit is contained in:
Lucas Batista 2024-09-05 15:24:40 -03:00
parent 33a5a503d9
commit 6003297bcf

View File

@ -867,6 +867,7 @@ 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.info('THIS IS WHEN CONTACTS ARE UPDATED ON DATABASE' + JSON.stringify(contacts))
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[] = [];
@ -1024,10 +1025,10 @@ export class BaileysStartupService extends ChannelStartupService {
await this.contactHandle['contacts.upsert']( await this.contactHandle['contacts.upsert'](
contacts contacts
.filter((c) => !!c.notify ?? !!c.name) .filter((c) => !!c.name || !!c.verifiedName || !!c.notify)
.map((c) => ({ .map((c) => ({
id: c.id, id: c.id,
name: c.name ?? c.notify, name: c.name || c.verifiedName || c.notify,
})), })),
database, database,
); );
@ -1254,7 +1255,9 @@ export class BaileysStartupService extends ChannelStartupService {
this.sendDataWebhook(Events.CONTACTS_UPSERT, contactRaw); this.sendDataWebhook(Events.CONTACTS_UPSERT, contactRaw);
this.logger.verbose('Inserting contact in database'); this.logger.verbose('Inserting contact in database');
this.repository.contact.insert([contactRaw], this.instance.name, database.SAVE_DATA.CONTACTS);
if (received?.key?.fromMe === false)
this.repository.contact.insert([contactRaw], this.instance.name, database.SAVE_DATA.CONTACTS);
} }
} catch (error) { } catch (error) {
this.logger.error(error); this.logger.error(error);