Soving problem status message

pull/21/head
adriano 2023-05-22 08:56:51 -03:00
parent 0a5c3fe7f3
commit 110c4007c8
1 changed files with 5 additions and 31 deletions

View File

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