From 064456ac8b344205afdfba0cf2d986e8a31f457f Mon Sep 17 00:00:00 2001 From: Claudemir Todo Bom Date: Mon, 1 Jul 2024 12:13:54 -0300 Subject: [PATCH] backend: revert commit c730e6aa08e641cf260a94a56d64a5d3a4e33ae3 --- backend/src/helpers/SetTicketMessagesAsRead.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/backend/src/helpers/SetTicketMessagesAsRead.ts b/backend/src/helpers/SetTicketMessagesAsRead.ts index 6628ba1c..594cf199 100644 --- a/backend/src/helpers/SetTicketMessagesAsRead.ts +++ b/backend/src/helpers/SetTicketMessagesAsRead.ts @@ -23,16 +23,11 @@ const SetTicketMessagesAsRead = async (ticket: Ticket): Promise => { }); companyid = getJsonMessage[0]?.companyId; - getJsonMessage.map(async m => { - const message: proto.IWebMessageInfo = JSON.parse(m.dataJson); - if (message.key) { - await (wbot as WASocket).readMessages([message.key]); - } - }); - if (getJsonMessage.length > 0) { - const lastMessages: proto.IWebMessageInfo = JSON.parse( getJsonMessage[0].dataJson ); - const number:string = ticket.isGroup ? `${ticket.contact.number.substring(12,0)}-${ticket.contact.number.substring(12)}@g.us` : `${ticket.contact.number}@s.whatsapp.net` + const lastMessages: proto.IWebMessageInfo = JSON.parse( + JSON.stringify(getJsonMessage[0].dataJson) + ); + const number = ticket.isGroup ? `${ticket.contact.number.substring(12,0)}-${ticket.contact.number.substring(12)}@g.us` : `${ticket.contact.number}@s.whatsapp.net` if (lastMessages.key && lastMessages.key.fromMe === false) { await (wbot as WASocket).chatModify( { markRead: true, lastMessages: [lastMessages] },