fix: ack before sending retry receipt

This commit is contained in:
Adhiraj Singh
2022-06-16 15:25:55 +05:30
parent 349002857e
commit bd6be89d57

View File

@@ -345,8 +345,6 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
} }
const handleReceipt = async(node: BinaryNode) => { const handleReceipt = async(node: BinaryNode) => {
let shouldAck = true
const { attrs, content } = node const { attrs, content } = node
const isNodeFromMe = areJidsSameUser(attrs.participant || attrs.from, authState.creds.me?.id) const isNodeFromMe = areJidsSameUser(attrs.participant || attrs.from, authState.creds.me?.id)
const remoteJid = !isNodeFromMe || isJidGroup(attrs.from) ? attrs.from : attrs.recipient const remoteJid = !isNodeFromMe || isJidGroup(attrs.from) ? attrs.from : attrs.recipient
@@ -399,9 +397,10 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
})) }))
) )
} }
} }
await sendMessageAck(node)
if(attrs.type === 'retry') { if(attrs.type === 'retry') {
// correctly set who is asking for the retry // correctly set who is asking for the retry
key.participant = key.participant || attrs.from key.participant = key.participant || attrs.from
@@ -412,7 +411,6 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
await sendMessagesAgain(key, ids) await sendMessagesAgain(key, ids)
} catch(error) { } catch(error) {
logger.error({ key, ids, trace: error.stack }, 'error in sending message again') logger.error({ key, ids, trace: error.stack }, 'error in sending message again')
shouldAck = false
} }
} else { } else {
logger.info({ attrs, key }, 'recv retry for not fromMe message') logger.info({ attrs, key }, 'recv retry for not fromMe message')
@@ -421,10 +419,6 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
logger.info({ attrs, key }, 'will not send message again, as sent too many times') logger.info({ attrs, key }, 'will not send message again, as sent too many times')
} }
} }
if(shouldAck) {
await sendMessageAck(node)
}
} }
) )
} }