@@ -139,9 +139,8 @@ import P from 'pino';
139139import qrcode , { QRCodeToDataURLOptions } from 'qrcode' ;
140140import qrcodeTerminal from 'qrcode-terminal' ;
141141import sharp from 'sharp' ;
142- import { PassThrough } from 'stream' ;
142+ import { PassThrough , Readable } from 'stream' ;
143143import { v4 } from 'uuid' ;
144- import { Readable } from 'stream' ;
145144
146145const groupMetadataCache = new CacheService ( new CacheEngine ( configService , 'groups' ) . getEngine ( ) ) ;
147146
@@ -372,7 +371,7 @@ export class BaileysStartupService extends ChannelStartupService {
372371 qrcodeTerminal . generate ( qr , { small : true } , ( qrcode ) =>
373372 this . logger . log (
374373 `\n{ instance: ${ this . instance . name } pairingCode: ${ this . instance . qrcode . pairingCode } , qrcodeCount: ${ this . instance . qrcode . count } }\n` +
375- qrcode ,
374+ qrcode ,
376375 ) ,
377376 ) ;
378377
@@ -976,18 +975,18 @@ export class BaileysStartupService extends ChannelStartupService {
976975
977976 const messagesRepository = new Set (
978977 chatwootImport . getRepositoryMessagesCache ( instance ) ??
979- (
980- await this . prismaRepository . message . findMany ( {
981- select : { key : true } ,
982- where : { instanceId : this . instanceId } ,
983- } )
984- ) . map ( ( message ) => {
985- const key = message . key as {
986- id : string ;
987- } ;
988-
989- return key . id ;
990- } ) ,
978+ (
979+ await this . prismaRepository . message . findMany ( {
980+ select : { key : true } ,
981+ where : { instanceId : this . instanceId } ,
982+ } )
983+ ) . map ( ( message ) => {
984+ const key = message . key as {
985+ id : string ;
986+ } ;
987+
988+ return key . id ;
989+ } ) ,
991990 ) ;
992991
993992 if ( chatwootImport . getRepositoryMessagesCache ( instance ) === null ) {
@@ -1138,7 +1137,7 @@ export class BaileysStartupService extends ChannelStartupService {
11381137 where : { instanceId : this . instanceId , remoteJid : received . key . remoteJid } ,
11391138 } ) ;
11401139
1141- if ( ! ! existingChat ) {
1140+ if ( existingChat ) {
11421141 const chatToInsert = {
11431142 remoteJid : received . key . remoteJid ,
11441143 instanceId : this . instanceId ,
@@ -1474,7 +1473,7 @@ export class BaileysStartupService extends ChannelStartupService {
14741473 where : { instanceId : this . instanceId , remoteJid : message . remoteJid } ,
14751474 } ) ;
14761475
1477- if ( ! ! existingChat ) {
1476+ if ( existingChat ) {
14781477 const chatToInsert = {
14791478 remoteJid : message . remoteJid ,
14801479 instanceId : this . instanceId ,
@@ -2507,9 +2506,7 @@ export class BaileysStartupService extends ChannelStartupService {
25072506
25082507 const prepareMedia = await prepareWAMessageMedia (
25092508 {
2510- [ type ] : isURL ( mediaMessage . media )
2511- ? { url : mediaMessage . media }
2512- : Buffer . from ( mediaMessage . media , 'base64' ) ,
2509+ [ type ] : isURL ( mediaMessage . media ) ? { url : mediaMessage . media } : Buffer . from ( mediaMessage . media , 'base64' ) ,
25132510 } as any ,
25142511 { upload : this . client . waUploadToServer } ,
25152512 ) ;
@@ -2564,7 +2561,7 @@ export class BaileysStartupService extends ChannelStartupService {
25642561 if ( mediaMessage . mediatype === 'ptv' ) {
25652562 prepareMedia [ mediaType ] = prepareMedia [ type + 'Message' ] ;
25662563 mimetype = 'video/mp4' ;
2567-
2564+
25682565 if ( ! prepareMedia [ mediaType ] ) {
25692566 throw new Error ( 'Failed to prepare video message' ) ;
25702567 }
@@ -2588,7 +2585,6 @@ export class BaileysStartupService extends ChannelStartupService {
25882585
25892586 this . logger . verbose ( `Video duration: ${ duration } seconds` ) ;
25902587 prepareMedia [ mediaType ] . seconds = duration ;
2591-
25922588 } catch ( error ) {
25932589 this . logger . error ( 'Error getting video duration:' ) ;
25942590 this . logger . error ( error ) ;
@@ -2954,43 +2950,43 @@ export class BaileysStartupService extends ChannelStartupService {
29542950 currency : button . currency ,
29552951 total_amount : {
29562952 value : 0 ,
2957- offset : 100
2953+ offset : 100 ,
29582954 } ,
29592955 reference_id : this . generateRandomId ( ) ,
2960- type : " physical-goods" ,
2956+ type : ' physical-goods' ,
29612957 order : {
2962- status : " pending" ,
2958+ status : ' pending' ,
29632959 subtotal : {
29642960 value : 0 ,
2965- offset : 100
2961+ offset : 100 ,
29662962 } ,
2967- order_type : " ORDER" ,
2963+ order_type : ' ORDER' ,
29682964 items : [
29692965 {
2970- name : "" ,
2966+ name : '' ,
29712967 amount : {
29722968 value : 0 ,
2973- offset : 100
2969+ offset : 100 ,
29742970 } ,
29752971 quantity : 0 ,
29762972 sale_amount : {
29772973 value : 0 ,
2978- offset : 100
2979- }
2980- }
2981- ]
2974+ offset : 100 ,
2975+ } ,
2976+ } ,
2977+ ] ,
29822978 } ,
29832979 payment_settings : [
29842980 {
2985- type : " pix_static_code" ,
2981+ type : ' pix_static_code' ,
29862982 pix_static_code : {
29872983 merchant_name : button . name ,
29882984 key : button . key ,
2989- key_type : this . mapKeyType . get ( button . keyType )
2990- }
2991- }
2985+ key_type : this . mapKeyType . get ( button . keyType ) ,
2986+ } ,
2987+ } ,
29922988 ] ,
2993- share_payment_status : false
2989+ share_payment_status : false ,
29942990 } ) ,
29952991 } ;
29962992
@@ -3018,11 +3014,11 @@ export class BaileysStartupService extends ChannelStartupService {
30183014 throw new BadRequestException ( 'At least one button is required' ) ;
30193015 }
30203016
3021- const hasReplyButtons = data . buttons . some ( btn => btn . type === 'reply' ) ;
3022-
3023- const hasPixButton = data . buttons . some ( btn => btn . type === 'pix' ) ;
3024-
3025- const hasOtherButtons = data . buttons . some ( btn => btn . type !== 'reply' && btn . type !== 'pix' ) ;
3017+ const hasReplyButtons = data . buttons . some ( ( btn ) => btn . type === 'reply' ) ;
3018+
3019+ const hasPixButton = data . buttons . some ( ( btn ) => btn . type === 'pix' ) ;
3020+
3021+ const hasOtherButtons = data . buttons . some ( ( btn ) => btn . type !== 'reply' && btn . type !== 'pix' ) ;
30263022
30273023 if ( hasReplyButtons ) {
30283024 if ( data . buttons . length > 3 ) {
@@ -3046,10 +3042,12 @@ export class BaileysStartupService extends ChannelStartupService {
30463042 message : {
30473043 interactiveMessage : {
30483044 nativeFlowMessage : {
3049- buttons : [ {
3050- name : this . mapType . get ( 'pix' ) ,
3051- buttonParamsJson : this . toJSONString ( data . buttons [ 0 ] ) ,
3052- } ] ,
3045+ buttons : [
3046+ {
3047+ name : this . mapType . get ( 'pix' ) ,
3048+ buttonParamsJson : this . toJSONString ( data . buttons [ 0 ] ) ,
3049+ } ,
3050+ ] ,
30533051 messageParamsJson : JSON . stringify ( {
30543052 from : 'api' ,
30553053 templateId : v4 ( ) ,
0 commit comments