@@ -1354,7 +1354,6 @@ export class WAStartupService {
13541354
13551355 if ( events . call ) {
13561356 this . logger . verbose ( 'Listening event: call' ) ;
1357- console . log ( 'events.call' , events . call ) ;
13581357 const call = events . call [ 0 ] ;
13591358
13601359 if ( settings ?. reject_call && call . status == 'offer' ) {
@@ -1662,8 +1661,6 @@ export class WAStartupService {
16621661
16631662 const linkPreview = options ?. linkPreview != false ? undefined : false ;
16641663
1665- console . log ( 'linkPreview' , linkPreview ) ;
1666-
16671664 let quoted : WAMessage ;
16681665
16691666 if ( options ?. quoted ) {
@@ -2179,26 +2176,45 @@ export class WAStartupService {
21792176
21802177 public async audioWhatsapp ( data : SendAudioDto ) {
21812178 this . logger . verbose ( 'Sending audio whatsapp' ) ;
2182- const convert = await this . processAudio ( data . audioMessage . audio , data . number ) ;
2183- if ( typeof convert === 'string' ) {
2184- const audio = fs . readFileSync ( convert ) . toString ( 'base64' ) ;
2185- const result = this . sendMessageWithTyping < AnyMessageContent > (
2186- data . number ,
2187- {
2188- audio : Buffer . from ( audio , 'base64' ) ,
2189- ptt : true ,
2190- mimetype : 'audio/mp4' ,
2191- } ,
2192- { presence : 'recording' , delay : data ?. options ?. delay } ,
2193- ) ;
21942179
2195- fs . unlinkSync ( convert ) ;
2196- this . logger . verbose ( 'Converted audio deleted' ) ;
2180+ if ( ! data . options ?. encoding && data . options ?. encoding !== false ) {
2181+ data . options . encoding = true ;
2182+ }
21972183
2198- return result ;
2199- } else {
2200- throw new InternalServerErrorException ( convert ) ;
2184+ if ( data . options ?. encoding ) {
2185+ const convert = await this . processAudio ( data . audioMessage . audio , data . number ) ;
2186+ if ( typeof convert === 'string' ) {
2187+ const audio = fs . readFileSync ( convert ) . toString ( 'base64' ) ;
2188+ const result = this . sendMessageWithTyping < AnyMessageContent > (
2189+ data . number ,
2190+ {
2191+ audio : Buffer . from ( audio , 'base64' ) ,
2192+ ptt : true ,
2193+ mimetype : 'audio/mp4' ,
2194+ } ,
2195+ { presence : 'recording' , delay : data ?. options ?. delay } ,
2196+ ) ;
2197+
2198+ fs . unlinkSync ( convert ) ;
2199+ this . logger . verbose ( 'Converted audio deleted' ) ;
2200+
2201+ return result ;
2202+ } else {
2203+ throw new InternalServerErrorException ( convert ) ;
2204+ }
22012205 }
2206+
2207+ return await this . sendMessageWithTyping < AnyMessageContent > (
2208+ data . number ,
2209+ {
2210+ audio : isURL ( data . audioMessage . audio )
2211+ ? { url : data . audioMessage . audio }
2212+ : Buffer . from ( data . audioMessage . audio , 'base64' ) ,
2213+ ptt : true ,
2214+ mimetype : 'audio/ogg; codecs=opus' ,
2215+ } ,
2216+ { presence : 'recording' , delay : data ?. options ?. delay } ,
2217+ ) ;
22022218 }
22032219
22042220 public async buttonMessage ( data : SendButtonDto ) {
0 commit comments