Skip to content

Commit 1aa837d

Browse files
committed
fix: Adjusts in chatwoot integration
1 parent 2f3d6f7 commit 1aa837d

3 files changed

Lines changed: 29 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
* Added link preview option in send text message
1414
* Fixed problem with fileSha256 appearing when sending a sticker in chatwoot
15+
* Fixed issue where it was not possible to open a conversation when sent at first by me on my cell phone in chatwoot
16+
* Now it only updates the contact name if it is the same as the phone number in chatwoot
1517

1618
### Integrations
1719

src/whatsapp/services/chatwoot.service.ts

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,12 @@ export class ChatwootService {
428428
);
429429

430430
if (findParticipant) {
431-
await this.updateContact(instance, findParticipant.id, {
432-
name: body.pushName,
433-
avatar_url: picture_url.profilePictureUrl || null,
434-
});
431+
if (!findParticipant.name || findParticipant.name === chatId) {
432+
await this.updateContact(instance, findParticipant.id, {
433+
name: body.pushName,
434+
avatar_url: picture_url.profilePictureUrl || null,
435+
});
436+
}
435437
} else {
436438
await this.createContact(
437439
instance,
@@ -454,13 +456,28 @@ export class ChatwootService {
454456

455457
let contact: any;
456458
if (body.key.fromMe) {
457-
contact = findContact;
459+
if (findContact) {
460+
contact = findContact;
461+
} else {
462+
contact = await this.createContact(
463+
instance,
464+
chatId,
465+
filterInbox.id,
466+
isGroup,
467+
nameContact,
468+
picture_url.profilePictureUrl || null,
469+
);
470+
}
458471
} else {
459472
if (findContact) {
460-
contact = await this.updateContact(instance, findContact.id, {
461-
name: nameContact,
462-
avatar_url: picture_url.profilePictureUrl || null,
463-
});
473+
if (!findContact.name || findContact.name === chatId) {
474+
contact = await this.updateContact(instance, findContact.id, {
475+
name: nameContact,
476+
avatar_url: picture_url.profilePictureUrl || null,
477+
});
478+
} else {
479+
contact = findContact;
480+
}
464481
} else {
465482
contact = await this.createContact(
466483
instance,
@@ -1299,8 +1316,6 @@ export class ChatwootService {
12991316
this.logger.verbose('get conversation message');
13001317
const bodyMessage = await this.getConversationMessage(body.message);
13011318

1302-
console.log('bodyMessage', bodyMessage, body.message);
1303-
13041319
if (!bodyMessage && !isMedia) {
13051320
this.logger.warn('no body message found');
13061321
return;

src/whatsapp/services/whatsapp.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ export class WAStartupService {
10931093

10941094
if (
10951095
type !== 'notify' ||
1096-
received.message?.protocolMessage ||
1096+
// received.message?.protocolMessage ||
10971097
received.message?.pollUpdateMessage
10981098
) {
10991099
this.logger.verbose('message rejected');

0 commit comments

Comments
 (0)