11import axios from 'axios' ;
22import { arrayUnique , isURL } from 'class-validator' ;
33import EventEmitter2 from 'eventemitter2' ;
4+ import FormData from 'form-data' ;
45import fs from 'fs/promises' ;
56import { getMIMEType } from 'node-mime-types' ;
67
@@ -298,8 +299,6 @@ export class BusinessStartupService extends WAStartupService {
298299 let messageRaw : MessageRaw ;
299300 let pushName : any ;
300301
301- console . log ( 'received?.messages[0]' , received ?. messages [ 0 ] ) ;
302-
303302 if ( received . contacts ) pushName = received . contacts [ 0 ] . profile . name ;
304303
305304 if ( received . messages ) {
@@ -756,7 +755,6 @@ export class BusinessStartupService extends WAStartupService {
756755 return messageRaw ;
757756 } catch ( error ) {
758757 this . logger . error ( error ) ;
759- console . log ( error . data ) ;
760758 throw new BadRequestException ( error . toString ( ) ) ;
761759 }
762760 }
@@ -779,9 +777,11 @@ export class BusinessStartupService extends WAStartupService {
779777 const integration = await this . findIntegration ( ) ;
780778
781779 const formData = new FormData ( ) ;
782- const arquivoBuffer = await fs . readFile ( mediaMessage . media ) ;
783- const arquivoBlob = new Blob ( [ arquivoBuffer ] , { type : mediaMessage . mimetype } ) ;
784- formData . append ( 'file' , arquivoBlob ) ;
780+
781+ const fileBuffer = await fs . readFile ( mediaMessage . media ) ;
782+
783+ const fileBlob = new Blob ( [ fileBuffer ] , { type : mediaMessage . mimetype } ) ;
784+ formData . append ( 'file' , fileBlob ) ;
785785 formData . append ( 'typeFile' , mediaMessage . mimetype ) ;
786786 formData . append ( 'messaging_product' , 'whatsapp' ) ;
787787 const headers = { Authorization : `Bearer ${ integration . token } ` } ;
0 commit comments