From 2e5147da33f59ab0c10aa9c45055a52b7a9e6a5b Mon Sep 17 00:00:00 2001 From: Bruno Cardoso Date: Mon, 1 Jul 2024 13:20:25 -0300 Subject: [PATCH] =?UTF-8?q?UPDATE=20SET=20TICKET=20MESSAGES=20AS=20READ=20?= =?UTF-8?q?-=20CORRE=C3=87=C3=83O=20DOS=20GRUPOS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/helpers/SetTicketMessagesAsRead.ts | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/backend/src/helpers/SetTicketMessagesAsRead.ts b/backend/src/helpers/SetTicketMessagesAsRead.ts index 6628ba1c..0b6b7baa 100644 --- a/backend/src/helpers/SetTicketMessagesAsRead.ts +++ b/backend/src/helpers/SetTicketMessagesAsRead.ts @@ -21,25 +21,21 @@ const SetTicketMessagesAsRead = async (ticket: Ticket): Promise => { }, order: [["createdAt", "DESC"]] }); - companyid = getJsonMessage[0]?.companyId; + 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]); - } - }); + 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` if (lastMessages.key && lastMessages.key.fromMe === false) { await (wbot as WASocket).chatModify( { markRead: true, lastMessages: [lastMessages] }, - number - // `${ticket.contact.number}@${ - // ticket.isGroup ? "g.us" : "s.whatsapp.net" - // }` + `${ticket.contact.number}@${ticket.isGroup ? "g.us" : "s.whatsapp.net"}` ); } }