Alteração para usar diretorio de mídias fora do diretorio do projeto

pull/21/head
adriano 2022-12-19 12:05:35 -03:00
parent ad9cbafdf2
commit 397c18d80f
2 changed files with 15 additions and 44 deletions

View File

@ -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,

View File

@ -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)) {