mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-23 04:22:02 -06:00
feat: Save picture url groups in chatwoot
This commit is contained in:
parent
f33a6aba39
commit
70f7c8ce89
@ -258,6 +258,7 @@ export class ChatwootService {
|
|||||||
inboxId: number,
|
inboxId: number,
|
||||||
isGroup: boolean,
|
isGroup: boolean,
|
||||||
name?: string,
|
name?: string,
|
||||||
|
avatar_url?: string,
|
||||||
) {
|
) {
|
||||||
this.logger.verbose('create contact to instance: ' + instance.instanceName);
|
this.logger.verbose('create contact to instance: ' + instance.instanceName);
|
||||||
|
|
||||||
@ -275,6 +276,7 @@ export class ChatwootService {
|
|||||||
inbox_id: inboxId,
|
inbox_id: inboxId,
|
||||||
name: name || phoneNumber,
|
name: name || phoneNumber,
|
||||||
phone_number: `+${phoneNumber}`,
|
phone_number: `+${phoneNumber}`,
|
||||||
|
avatar_url: avatar_url,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
this.logger.verbose('create contact group in chatwoot');
|
this.logger.verbose('create contact group in chatwoot');
|
||||||
@ -282,6 +284,7 @@ export class ChatwootService {
|
|||||||
inbox_id: inboxId,
|
inbox_id: inboxId,
|
||||||
name: name || phoneNumber,
|
name: name || phoneNumber,
|
||||||
identifier: phoneNumber,
|
identifier: phoneNumber,
|
||||||
|
avatar_url: avatar_url,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,27 +407,58 @@ export class ChatwootService {
|
|||||||
nameContact = `${group.subject} (GROUP)`;
|
nameContact = `${group.subject} (GROUP)`;
|
||||||
|
|
||||||
this.logger.verbose('find or create participant in chatwoot');
|
this.logger.verbose('find or create participant in chatwoot');
|
||||||
const participant =
|
|
||||||
(await this.findContact(instance, body.key.participant.split('@')[0])) ||
|
const picture_url = await this.waMonitor.waInstances[
|
||||||
((await this.createContact(
|
instance.instanceName
|
||||||
|
].profilePicture(body.key.participant.split('@')[0]);
|
||||||
|
|
||||||
|
const findParticipant = await this.findContact(
|
||||||
|
instance,
|
||||||
|
body.key.participant.split('@')[0],
|
||||||
|
);
|
||||||
|
|
||||||
|
if (findParticipant) {
|
||||||
|
await this.updateContact(instance, findParticipant.id, {
|
||||||
|
name: nameContact,
|
||||||
|
avatar_url: picture_url.profilePictureUrl || null,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await this.createContact(
|
||||||
instance,
|
instance,
|
||||||
body.key.participant.split('@')[0],
|
body.key.participant.split('@')[0],
|
||||||
filterInbox.id,
|
filterInbox.id,
|
||||||
false,
|
isGroup,
|
||||||
body.pushName || body.key.participant.split('@')[0],
|
nameContact,
|
||||||
)) as any);
|
picture_url.profilePictureUrl || null,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.verbose('find or create contact in chatwoot');
|
this.logger.verbose('find or create contact in chatwoot');
|
||||||
const contact =
|
|
||||||
(await this.findContact(instance, chatId)) ||
|
const picture_url = await this.waMonitor.waInstances[
|
||||||
((await this.createContact(
|
instance.instanceName
|
||||||
|
].profilePicture(chatId);
|
||||||
|
|
||||||
|
const findContact = await this.findContact(instance, chatId);
|
||||||
|
|
||||||
|
let contact: any;
|
||||||
|
|
||||||
|
if (findContact) {
|
||||||
|
contact = await this.updateContact(instance, findContact.id, {
|
||||||
|
name: nameContact,
|
||||||
|
avatar_url: picture_url.profilePictureUrl || null,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
contact = await this.createContact(
|
||||||
instance,
|
instance,
|
||||||
chatId,
|
chatId,
|
||||||
filterInbox.id,
|
filterInbox.id,
|
||||||
isGroup,
|
isGroup,
|
||||||
nameContact,
|
nameContact,
|
||||||
)) as any);
|
picture_url.profilePictureUrl || null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!contact) {
|
if (!contact) {
|
||||||
this.logger.warn('contact not found');
|
this.logger.warn('contact not found');
|
||||||
|
Loading…
Reference in New Issue
Block a user