From 397c18d80f4176447f2de35fd571d0c08397e014 Mon Sep 17 00:00:00 2001 From: adriano Date: Mon, 19 Dec 2022 12:05:35 -0300 Subject: [PATCH] =?UTF-8?q?Altera=C3=A7=C3=A3o=20para=20usar=20diretorio?= =?UTF-8?q?=20de=20m=C3=ADdias=20fora=20do=20diretorio=20do=20projeto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/config/upload.ts | 6 ++- .../WbotServices/wbotMessageListener.ts | 53 ++++--------------- 2 files changed, 15 insertions(+), 44 deletions(-) diff --git a/backend/src/config/upload.ts b/backend/src/config/upload.ts index 24fb8f8..e7d682d 100644 --- a/backend/src/config/upload.ts +++ b/backend/src/config/upload.ts @@ -1,7 +1,11 @@ import path from "path"; import multer from "multer"; -const publicFolder = path.resolve(__dirname, "..", "..", "public"); +// const publicFolder = path.resolve(__dirname, "..", "..", "public"); +const publicFolder = path.resolve(__dirname, "..", "..","..","..", "public"); + +console.log('publicFolder: ',publicFolder) + export default { directory: publicFolder, diff --git a/backend/src/services/WbotServices/wbotMessageListener.ts b/backend/src/services/WbotServices/wbotMessageListener.ts index f504bae..c2132f2 100644 --- a/backend/src/services/WbotServices/wbotMessageListener.ts +++ b/backend/src/services/WbotServices/wbotMessageListener.ts @@ -118,8 +118,14 @@ const verifyMediaMessage = async ( } try { + // await writeFileAsync( + // join(__dirname, "..", "..", "..", "public", media.filename), + // media.data, + // "base64" + // ); + await writeFileAsync( - join(__dirname, "..", "..", "..", "public", media.filename), + join(__dirname, "..", "..", "..", "..", "..", "public", media.filename), media.data, "base64" ); @@ -365,19 +371,11 @@ const botSendMessage = (ticket: Ticket, contact: Contact, wbot: Session, msg: st const _clear_lst = () => { - console.log('WHATSAPP MESSAGE ID MULTI SESSION: ', lst.length) - - if (lst.length <= 200 ) return - - console.log('BEFORE lst SLICE: ', lst) - - console.log('lst whatsapp message id sliced! | lst.length: ', lst.length) + if (lst.length <= 200 ) return const chunk: any = Math.floor((lst.length / 2)) - lst = lst.slice(chunk, chunk + lst.length); - - console.log('AFTER lst SLICE: ', lst) + lst = lst.slice(chunk, chunk + lst.length); } @@ -426,38 +424,7 @@ const handleMessage = async ( // console.log('LIST OF ID MESSAGE lst: ', lst) - console.log('PASSOU.................................FROM: ', msg.from.split("@")[0], ' | ID: ', msg.id.id) - - // const contact_message = await getLastId(`contact_message:5517988310949`) - - // if (contact_message && contact_message.id == msg.id.id) { - // console.log('IGNORED MESSAGE SAME ID FROM CLIENT: ', contact_message.id) - // return - // } - - // await insertMessageContactCache(`contact_message:5517988310949`, - // { - // from: msg.from.split("@")[0], - // to: msg.to.split("@")[0], - // id: msg.id.id - // }) - - // console.log('PASSOU............................................... contact_message.id: ',contact_message.id) - - - // if (testLastId == msg.id.id) { - // console.log('IGNORED MESSAGE SAME ID!') - // return - // } - // testLastId = msg.id.id - - // console.log('PASSOU............................................... msg.id.id: ',msg.id.id) - - - - - - + console.log('PASSOU.................................FROM: ', msg.from.split("@")[0], ' | ID: ', msg.id.id) if (!isValidMsg(msg)) {