From a0003f0fe97572b4ebe37eef54898d4dbf96fa36 Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Fri, 7 Jan 2022 21:24:46 +0530 Subject: [PATCH] fix: read receipts not being available --- src/Socket/messages-recv.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Socket/messages-recv.ts b/src/Socket/messages-recv.ts index 7c62e00..b33ff80 100644 --- a/src/Socket/messages-recv.ts +++ b/src/Socket/messages-recv.ts @@ -429,9 +429,9 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => { let shouldAck = true const { attrs, content } = node - const isNodeFromMe = areJidsSameUser(attrs.from, authState.creds.me?.id) - const remoteJid = attrs.recipient || attrs.from - const fromMe = isNodeFromMe || (attrs.recipient ? false : true) + const isNodeFromMe = areJidsSameUser(attrs.participant || attrs.from, authState.creds.me?.id) + const remoteJid = !isNodeFromMe ? attrs.from : attrs.recipient + const fromMe = !attrs.recipient const ids = [attrs.id] if(Array.isArray(content)) { @@ -447,7 +447,15 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => { } const status = getStatusFromReceiptType(attrs.type) - if(typeof status !== 'undefined' && !isNodeFromMe) { + if( + typeof status !== 'undefined' && + ( + // basically, we only want to know when a message from us has been delivered to/read by the other person + // or another device of ours has read some messages + status > proto.WebMessageInfo.WebMessageInfoStatus.DELIVERY_ACK || + !isNodeFromMe + ) + ) { ev.emit('messages.update', ids.map(id => ({ key: { ...key, id }, update: { status }