Skip to content

Commit b4a9941

Browse files
committed
feat: Native integration with chatwoot
1 parent be782ba commit b4a9941

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/whatsapp/services/chatwoot.service.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ export class ChatwootService {
4646
instance.instanceName
4747
].findChatwoot();
4848

49+
if (!provider) {
50+
return null;
51+
}
52+
4953
return provider;
5054
}
5155

@@ -102,6 +106,10 @@ export class ChatwootService {
102106
id,
103107
});
104108

109+
if (!contact) {
110+
return null;
111+
}
112+
105113
return contact;
106114
}
107115

@@ -126,6 +134,10 @@ export class ChatwootService {
126134
},
127135
});
128136

137+
if (!contact) {
138+
return null;
139+
}
140+
129141
return contact;
130142
}
131143

@@ -536,7 +548,7 @@ export class ChatwootService {
536548
formatText = messageReceived;
537549
} else {
538550
formatText = this.provider.sign_msg
539-
? `*${senderName}*: ${messageReceived}`
551+
? `*${senderName}:*\n\n${messageReceived}`
540552
: messageReceived;
541553
}
542554

@@ -631,10 +643,6 @@ export class ChatwootService {
631643
const waInstance = this.waMonitor.waInstances[instance.instanceName];
632644

633645
if (event === 'messages.upsert') {
634-
// if (body.key.fromMe && !IMPORT_MESSAGES_SENT) {
635-
// return;
636-
// }
637-
638646
if (body.key.remoteJid === 'status@broadcast') {
639647
return;
640648
}
@@ -699,6 +707,11 @@ export class ChatwootService {
699707
if (event === 'status.instance') {
700708
const data = body;
701709
const inbox = await this.getInbox(instance);
710+
711+
if (!inbox) {
712+
return;
713+
}
714+
702715
const msgStatus = `⚡️ Status da instância ${inbox.name}: ${data.status}`;
703716
await this.createBotMessage(instance, msgStatus, 'incoming');
704717
}

0 commit comments

Comments
 (0)