mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-11 10:59:37 -06:00
fix: respect DATABASE_SAVE_DATA_CONTACTS in contact updates
This commit is contained in:
parent
df20c5fc93
commit
53a94af3f7
@ -839,10 +839,14 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
this.sendDataWebhook(Events.CONTACTS_UPDATE, updatedContacts);
|
this.sendDataWebhook(Events.CONTACTS_UPDATE, updatedContacts);
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
updatedContacts.map(async (contact) => {
|
updatedContacts.map(async (contact) => {
|
||||||
const update = this.prismaRepository.contact.updateMany({
|
let update;
|
||||||
|
if (this.configService.get<Database>('DATABASE').SAVE_DATA.CONTACTS) {
|
||||||
|
update = this.prismaRepository.contact.updateMany({
|
||||||
where: { remoteJid: contact.remoteJid, instanceId: this.instanceId },
|
where: { remoteJid: contact.remoteJid, instanceId: this.instanceId },
|
||||||
data: { profilePicUrl: contact.profilePicUrl },
|
data: { profilePicUrl: contact.profilePicUrl },
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled) {
|
if (this.configService.get<Chatwoot>('CHATWOOT').ENABLED && this.localChatwoot?.enabled) {
|
||||||
const instance = { instanceName: this.instance.name, instanceId: this.instance.id };
|
const instance = { instanceName: this.instance.name, instanceId: this.instance.id };
|
||||||
@ -886,6 +890,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
|
|
||||||
this.sendDataWebhook(Events.CONTACTS_UPDATE, contactsRaw);
|
this.sendDataWebhook(Events.CONTACTS_UPDATE, contactsRaw);
|
||||||
|
|
||||||
|
if (this.configService.get<Database>('DATABASE').SAVE_DATA.CONTACTS) {
|
||||||
const updateTransactions = contactsRaw.map((contact) =>
|
const updateTransactions = contactsRaw.map((contact) =>
|
||||||
this.prismaRepository.contact.upsert({
|
this.prismaRepository.contact.upsert({
|
||||||
where: { remoteJid_instanceId: { remoteJid: contact.remoteJid, instanceId: contact.instanceId } },
|
where: { remoteJid_instanceId: { remoteJid: contact.remoteJid, instanceId: contact.instanceId } },
|
||||||
@ -894,6 +899,8 @@ export class BaileysStartupService extends ChannelStartupService {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
await this.prismaRepository.$transaction(updateTransactions);
|
await this.prismaRepository.$transaction(updateTransactions);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//const usersContacts = contactsRaw.filter((c) => c.remoteJid.includes('@s.whatsapp'));
|
//const usersContacts = contactsRaw.filter((c) => c.remoteJid.includes('@s.whatsapp'));
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user