@@ -1193,7 +1193,7 @@ export class WAStartupService {
11931193 ...options ,
11941194 auth : {
11951195 creds : this . instance . authState . state . creds ,
1196- keys : makeCacheableSignalKeyStore ( this . instance . authState . state . keys , P ( { level : 'error' } ) ) ,
1196+ keys : makeCacheableSignalKeyStore ( this . instance . authState . state . keys , P ( { level : 'error' } ) as any ) ,
11971197 } ,
11981198 logger : P ( { level : this . logBaileys } ) ,
11991199 printQRInTerminal : false ,
@@ -1273,7 +1273,7 @@ export class WAStartupService {
12731273 ...options ,
12741274 auth : {
12751275 creds : this . instance . authState . state . creds ,
1276- keys : makeCacheableSignalKeyStore ( this . instance . authState . state . keys , P ( { level : 'error' } ) ) ,
1276+ keys : makeCacheableSignalKeyStore ( this . instance . authState . state . keys , P ( { level : 'error' } ) as any ) ,
12771277 } ,
12781278 logger : P ( { level : this . logBaileys } ) ,
12791279 printQRInTerminal : false ,
@@ -1542,7 +1542,7 @@ export class WAStartupService {
15421542 'buffer' ,
15431543 { } ,
15441544 {
1545- logger : P ( { level : 'error' } ) ,
1545+ logger : P ( { level : 'error' } ) as any ,
15461546 reuploadRequest : this . client . updateMediaMessage ,
15471547 } ,
15481548 ) ;
@@ -2061,7 +2061,12 @@ export class WAStartupService {
20612061 }
20622062 }
20632063
2064- private async sendMessageWithTyping < T = proto . IMessage > ( number : string , message : T , options ?: Options ) {
2064+ private async sendMessageWithTyping < T = proto . IMessage > (
2065+ number : string ,
2066+ message : T ,
2067+ options ?: Options ,
2068+ isChatwoot = false ,
2069+ ) {
20652070 this . logger . verbose ( 'Sending message with typing' ) ;
20662071
20672072 this . logger . verbose ( `Check if number "${ number } " is WhatsApp` ) ;
@@ -2219,7 +2224,7 @@ export class WAStartupService {
22192224 this . logger . verbose ( 'Sending data to webhook in event SEND_MESSAGE' ) ;
22202225 await this . sendDataWebhook ( Events . SEND_MESSAGE , messageRaw ) ;
22212226
2222- if ( this . localChatwoot . enabled ) {
2227+ if ( this . localChatwoot . enabled && ! isChatwoot ) {
22232228 this . chatwootService . eventWhatsapp ( Events . SEND_MESSAGE , { instanceName : this . instance . name } , messageRaw ) ;
22242229 }
22252230
@@ -2244,14 +2249,15 @@ export class WAStartupService {
22442249 }
22452250
22462251 // Send Message Controller
2247- public async textMessage ( data : SendTextDto ) {
2252+ public async textMessage ( data : SendTextDto , isChatwoot = false ) {
22482253 this . logger . verbose ( 'Sending text message' ) ;
22492254 return await this . sendMessageWithTyping (
22502255 data . number ,
22512256 {
22522257 conversation : data . textMessage . text ,
22532258 } ,
22542259 data ?. options ,
2260+ isChatwoot ,
22552261 ) ;
22562262 }
22572263
@@ -2528,11 +2534,11 @@ export class WAStartupService {
25282534 return result ;
25292535 }
25302536
2531- public async mediaMessage ( data : SendMediaDto ) {
2537+ public async mediaMessage ( data : SendMediaDto , isChatwoot = false ) {
25322538 this . logger . verbose ( 'Sending media message' ) ;
25332539 const generate = await this . prepareMediaMessage ( data . mediaMessage ) ;
25342540
2535- return await this . sendMessageWithTyping ( data . number , { ...generate . message } , data ?. options ) ;
2541+ return await this . sendMessageWithTyping ( data . number , { ...generate . message } , data ?. options , isChatwoot ) ;
25362542 }
25372543
25382544 public async processAudio ( audio : string , number : string ) {
@@ -2589,7 +2595,7 @@ export class WAStartupService {
25892595 } ) ;
25902596 }
25912597
2592- public async audioWhatsapp ( data : SendAudioDto ) {
2598+ public async audioWhatsapp ( data : SendAudioDto , isChatwoot = false ) {
25932599 this . logger . verbose ( 'Sending audio whatsapp' ) ;
25942600
25952601 if ( ! data . options ?. encoding && data . options ?. encoding !== false ) {
@@ -2608,6 +2614,7 @@ export class WAStartupService {
26082614 mimetype : 'audio/mp4' ,
26092615 } ,
26102616 { presence : 'recording' , delay : data ?. options ?. delay } ,
2617+ isChatwoot ,
26112618 ) ;
26122619
26132620 fs . unlinkSync ( convert ) ;
@@ -2629,6 +2636,7 @@ export class WAStartupService {
26292636 mimetype : 'audio/ogg; codecs=opus' ,
26302637 } ,
26312638 { presence : 'recording' , delay : data ?. options ?. delay } ,
2639+ isChatwoot ,
26322640 ) ;
26332641 }
26342642
@@ -2939,7 +2947,7 @@ export class WAStartupService {
29392947 'buffer' ,
29402948 { } ,
29412949 {
2942- logger : P ( { level : 'error' } ) ,
2950+ logger : P ( { level : 'error' } ) as any ,
29432951 reuploadRequest : this . client . updateMediaMessage ,
29442952 } ,
29452953 ) ;
0 commit comments