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
* 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

View File

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

View File

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