Skip to content

Commit

Permalink
revert the reversion
Browse files Browse the repository at this point in the history
  • Loading branch information
allgood committed Jul 1, 2024
1 parent 6e55cae commit 648ffa1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions backend/src/helpers/SetTicketMessagesAsRead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@ const SetTicketMessagesAsRead = async (ticket: Ticket): Promise<void> => {
});
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(
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`
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] },
Expand Down

0 comments on commit 648ffa1

Please sign in to comment.