fix: Adjusts in chatwoot integration

This commit is contained in:
Davidson Gomes 2023-07-24 11:58:52 -03:00
parent 2f3d6f7e63
commit 1aa837d220
3 changed files with 29 additions and 12 deletions

View File

@ -12,6 +12,8 @@
* Added link preview option in send text message * Added link preview option in send text message
* Fixed problem with fileSha256 appearing when sending a sticker in chatwoot * Fixed problem with fileSha256 appearing when sending a sticker in chatwoot
* Fixed issue where it was not possible to open a conversation when sent at first by me on my cell phone in chatwoot
* Now it only updates the contact name if it is the same as the phone number in chatwoot
### Integrations ### Integrations

View File

@ -428,10 +428,12 @@ export class ChatwootService {
); );
if (findParticipant) { if (findParticipant) {
await this.updateContact(instance, findParticipant.id, { if (!findParticipant.name || findParticipant.name === chatId) {
name: body.pushName, await this.updateContact(instance, findParticipant.id, {
avatar_url: picture_url.profilePictureUrl || null, name: body.pushName,
}); avatar_url: picture_url.profilePictureUrl || null,
});
}
} else { } else {
await this.createContact( await this.createContact(
instance, instance,
@ -454,13 +456,28 @@ export class ChatwootService {
let contact: any; let contact: any;
if (body.key.fromMe) { if (body.key.fromMe) {
contact = findContact; if (findContact) {
contact = findContact;
} else {
contact = await this.createContact(
instance,
chatId,
filterInbox.id,
isGroup,
nameContact,
picture_url.profilePictureUrl || null,
);
}
} else { } else {
if (findContact) { if (findContact) {
contact = await this.updateContact(instance, findContact.id, { if (!findContact.name || findContact.name === chatId) {
name: nameContact, contact = await this.updateContact(instance, findContact.id, {
avatar_url: picture_url.profilePictureUrl || null, name: nameContact,
}); avatar_url: picture_url.profilePictureUrl || null,
});
} else {
contact = findContact;
}
} else { } else {
contact = await this.createContact( contact = await this.createContact(
instance, instance,
@ -1299,8 +1316,6 @@ export class ChatwootService {
this.logger.verbose('get conversation message'); this.logger.verbose('get conversation message');
const bodyMessage = await this.getConversationMessage(body.message); const bodyMessage = await this.getConversationMessage(body.message);
console.log('bodyMessage', bodyMessage, body.message);
if (!bodyMessage && !isMedia) { if (!bodyMessage && !isMedia) {
this.logger.warn('no body message found'); this.logger.warn('no body message found');
return; return;

View File

@ -1093,7 +1093,7 @@ export class WAStartupService {
if ( if (
type !== 'notify' || type !== 'notify' ||
received.message?.protocolMessage || // received.message?.protocolMessage ||
received.message?.pollUpdateMessage received.message?.pollUpdateMessage
) { ) {
this.logger.verbose('message rejected'); this.logger.verbose('message rejected');