From 34ee9647d3abd6c9155dd8e5254c090cdecf967c Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Mon, 27 Sep 2021 12:58:03 +0530 Subject: [PATCH] fix receipt from other device not working --- src/Socket/messages-recv.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Socket/messages-recv.ts b/src/Socket/messages-recv.ts index 3d4f979..7f35e14 100644 --- a/src/Socket/messages-recv.ts +++ b/src/Socket/messages-recv.ts @@ -360,8 +360,13 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => { logger.debug({ attrs: node.attrs }, 'sending receipt for ack') }) - const handleReceipt = ({ attrs, content }: BinaryNode) => { - const sender = attrs.participant || attrs.from + const handleReceipt = ({ tag, attrs, content }: BinaryNode) => { + if(tag === 'receipt') { + // if not read or no type (no type = delivered, but message sent from other device) + if(attrs.type !== 'read' && !!attrs.type) { + return + } + } const status = attrs.type === 'read' ? proto.WebMessageInfo.WebMessageInfoStatus.READ : proto.WebMessageInfo.WebMessageInfoStatus.DELIVERY_ACK const ids = [attrs.id] if(Array.isArray(content)) { @@ -380,7 +385,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => { }))) } - ws.on('CB:receipt,type:read', handleReceipt) + ws.on('CB:receipt', handleReceipt) ws.on('CB:ack,class:message', handleReceipt) ws.on('CB:notification', async(node: BinaryNode) => {