From 110c4007c870429b3f58fc81e939c665e72ccb76 Mon Sep 17 00:00:00 2001 From: adriano Date: Mon, 22 May 2023 08:56:51 -0300 Subject: [PATCH] Soving problem status message --- .../WbotServices/wbotMessageListener.ts | 36 +++---------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/backend/src/services/WbotServices/wbotMessageListener.ts b/backend/src/services/WbotServices/wbotMessageListener.ts index 2d9ff3b..bac461e 100644 --- a/backend/src/services/WbotServices/wbotMessageListener.ts +++ b/backend/src/services/WbotServices/wbotMessageListener.ts @@ -430,7 +430,7 @@ const handleMessage = async ( if (index == -1) { - // console.log('-----------------> LST: ', lst) + // console.log('-----------------> LST: ', lst):q lst.push({ id: msg.id.id }) @@ -900,39 +900,12 @@ const handleMessage = async ( } catch (err) { Sentry.captureException(err); - logger.error(`Error handling whatsapp message: Err: ${err}`); - - const whatsapp = await ShowWhatsAppService(wbot.id!); - - //Solução para contornar erro de sessão - if ((`${err}`).includes("Evaluation failed: r")) { - - const sourcePath = path.join(__dirname, `../../../.wwebjs_auth/sessions/log`) - - let log = new Date(new Date() + 'UTC'); - const dateToday = splitDateTime(new Date(format(new Date(), 'yyyy-MM-dd HH:mm:ss', { locale: ptBR }))) - - if (whatsapp.status == 'CONNECTED') { - - let timestamp = Math.floor(Date.now() / 1000) - - fs.writeFile(`${sourcePath}/${timestamp}_wbotMessageListener.txt`, `Whatsapp id: ${whatsapp.id} \nDate: ${dateToday.fullDate} ${dateToday.fullTime} \nFile: wbotMessageListener.ts \nError: ${err}`, (error) => { }); - - // await restartWhatsSession(whatsapp) - - } - - } - else if (`${err}`.includes('[object Object]')) { - - await _restore(whatsapp, 'auto_object_error') - - } - + logger.error(`Error handling whatsapp message: Err: ${err}`); } }; const handleMsgAck = async (msg_id: any, ack: any) => { + await new Promise(r => setTimeout(r, 500)); const io = getIO(); @@ -949,11 +922,12 @@ const handleMsgAck = async (msg_id: any, ack: any) => { ] }); if (!messageToUpdate) { + console.log(`Not found the MESSAGE ID ${msg_id}to change the ACK into the Message table`) return; } await messageToUpdate.update({ ack }); - // console.log('ACK messageToUpdate: ', JSON.parse(JSON.stringify(messageToUpdate))) + console.log('ACK messageToUpdate: ', JSON.parse(JSON.stringify(messageToUpdate))) io.to(messageToUpdate.ticketId.toString()).emit("appMessage", { action: "update",