mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-23 04:22:02 -06:00
Extracted profile picture request from contacts.upsert function
This commit is contained in:
parent
32026d1fd4
commit
27900c214f
@ -1657,7 +1657,7 @@ export class WAStartupService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
this.logger.verbose('Verifying if contacts exists in database to insert');
|
this.logger.verbose('Verifying if contacts exists in database to insert');
|
||||||
const contactsRaw: ContactRaw[] = [];
|
let contactsRaw: ContactRaw[] = [];
|
||||||
|
|
||||||
for (const contact of contacts) {
|
for (const contact of contacts) {
|
||||||
if (contactsRepository.has(contact.id)) {
|
if (contactsRepository.has(contact.id)) {
|
||||||
@ -1667,7 +1667,7 @@ export class WAStartupService {
|
|||||||
contactsRaw.push({
|
contactsRaw.push({
|
||||||
id: contact.id,
|
id: contact.id,
|
||||||
pushName: contact?.name || contact?.verifiedName || contact.id.split('@')[0],
|
pushName: contact?.name || contact?.verifiedName || contact.id.split('@')[0],
|
||||||
profilePictureUrl: (await this.profilePicture(contact.id)).profilePictureUrl,
|
profilePictureUrl: null,
|
||||||
owner: this.instance.name,
|
owner: this.instance.name,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1682,6 +1682,23 @@ export class WAStartupService {
|
|||||||
this.chatwootService.addHistoryContacts({ instanceName: this.instance.name }, contactsRaw);
|
this.chatwootService.addHistoryContacts({ instanceName: this.instance.name }, contactsRaw);
|
||||||
chatwootImport.importHistoryContacts({ instanceName: this.instance.name }, this.localChatwoot);
|
chatwootImport.importHistoryContacts({ instanceName: this.instance.name }, this.localChatwoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update profile pictures
|
||||||
|
contactsRaw = [];
|
||||||
|
for await (const contact of contacts) {
|
||||||
|
contactsRaw.push({
|
||||||
|
id: contact.id,
|
||||||
|
pushName: contact?.name || contact?.verifiedName || contact.id.split('@')[0],
|
||||||
|
profilePictureUrl: (await this.profilePicture(contact.id)).profilePictureUrl,
|
||||||
|
owner: this.instance.name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.verbose('Sending data to webhook in event CONTACTS_UPDATE');
|
||||||
|
this.sendDataWebhook(Events.CONTACTS_UPSERT, contactsRaw);
|
||||||
|
|
||||||
|
this.logger.verbose('Updating contacts in database');
|
||||||
|
this.repository.contact.update(contactsRaw, 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