From d5b857ad61a68fbc6b03383a908e7c67e4d526db Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Sun, 7 Aug 2022 11:14:06 +0530 Subject: [PATCH] fix: possible ack issue --- src/Socket/messages-recv.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Socket/messages-recv.ts b/src/Socket/messages-recv.ts index 0d64827..ea5681b 100644 --- a/src/Socket/messages-recv.ts +++ b/src/Socket/messages-recv.ts @@ -5,7 +5,7 @@ import { MessageReceiptType, MessageRelayOptions, MessageUserReceipt, SocketConf import { decodeMediaRetryNode, decodeMessageStanza, delay, encodeBigEndian, getCallStatusFromNode, getNextPreKeys, getStatusFromReceiptType, isHistoryMsg, unixTimestampSeconds, xmppPreKey, xmppSignedPreKey } from '../Utils' import { makeMutex } from '../Utils/make-mutex' import { cleanMessage } from '../Utils/process-message' -import { areJidsSameUser, BinaryNode, BinaryNodeAttributes, getAllBinaryNodeChildren, getBinaryNodeChild, getBinaryNodeChildren, isJidGroup, isJidUser, jidDecode, jidNormalizedUser, S_WHATSAPP_NET } from '../WABinary' +import { areJidsSameUser, BinaryNode, getAllBinaryNodeChildren, getBinaryNodeChild, getBinaryNodeChildren, isJidGroup, isJidUser, jidDecode, jidNormalizedUser, S_WHATSAPP_NET } from '../WABinary' import { extractGroupMetadata } from './groups' import { makeMessagesSocket } from './messages-send' @@ -39,14 +39,13 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => { let sendActiveReceipts = false - const sendMessageAck = async({ tag, attrs }: BinaryNode, extraAttrs: BinaryNodeAttributes = { }) => { + const sendMessageAck = async({ tag, attrs }: BinaryNode) => { const stanza: BinaryNode = { tag: 'ack', attrs: { id: attrs.id, to: attrs.from, class: tag, - ...extraAttrs, } } @@ -54,7 +53,11 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => { stanza.attrs.participant = attrs.participant } - if(tag !== 'message' && attrs.type && !extraAttrs.type) { + if(!!attrs.recipient) { + stanza.attrs.recipient = attrs.recipient + } + + if(tag !== 'message' && attrs.type) { stanza.attrs.type = attrs.type } @@ -516,7 +519,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => { ev.emit('call', [call]) - await sendMessageAck(node, { type: infoChild.tag }) + await sendMessageAck(node) } const handleBadAck = async({ attrs }: BinaryNode) => {