receipt ack fix

This commit is contained in:
Adhiraj Singh
2021-10-07 12:57:02 +05:30
parent e6bc1916c2
commit c5d8389754

View File

@@ -148,8 +148,8 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
case proto.ProtocolMessage.ProtocolMessageType.REVOKE: case proto.ProtocolMessage.ProtocolMessageType.REVOKE:
ev.emit('messages.update', [ ev.emit('messages.update', [
{ {
key: message.key, key: protocolMsg.key,
update: { message: null, messageStubType: WAMessageStubType.REVOKE, key: protocolMsg.key } update: { message: null, messageStubType: WAMessageStubType.REVOKE, key: message.key }
} }
]) ])
break break
@@ -306,10 +306,6 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
const isGroup = !!stanza.attrs.participant const isGroup = !!stanza.attrs.participant
const sender = (attrs.participant || attrs.from)?.toString() const sender = (attrs.participant || attrs.from)?.toString()
const isMe = areJidsSameUser(sender, authState.creds.me!.id) const isMe = areJidsSameUser(sender, authState.creds.me!.id)
await sendMessageAck(stanza)
logger.debug({ msgId: dec.msgId, sender }, 'send message ack')
// send delivery receipt // send delivery receipt
let recpAttrs: { [_: string]: any } let recpAttrs: { [_: string]: any }
@@ -327,17 +323,22 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
} else { } else {
const isStatus = isJidStatusBroadcast(stanza.attrs.from) const isStatus = isJidStatusBroadcast(stanza.attrs.from)
recpAttrs = { recpAttrs = {
//type: 'inactive', type: 'inactive',
id: stanza.attrs.id, id: stanza.attrs.id,
to: dec.chatId,
} }
if(isGroup || isStatus) { if(isGroup || isStatus) {
recpAttrs.participant = stanza.attrs.participant recpAttrs.participant = stanza.attrs.participant
recpAttrs.to = dec.chatId
} else {
recpAttrs.to = jidEncode(jidDecode(dec.chatId).user, 'c.us')
} }
} }
await sendNode({ tag: 'receipt', attrs: recpAttrs }) await sendNode({ tag: 'receipt', attrs: recpAttrs })
logger.debug({ msgId: dec.msgId }, 'sent message receipt')
logger.debug({ msgId: dec.msgId }, 'send message receipt') await sendMessageAck(stanza)
logger.debug({ msgId: dec.msgId, sender }, 'sent message ack')
const message = msg.deviceSentMessage?.message || msg const message = msg.deviceSentMessage?.message || msg
fullMessages.push({ fullMessages.push({