fix: possible ack fix

This commit is contained in:
Adhiraj Singh
2021-11-09 13:40:59 +05:30
parent cd59b8fc97
commit cfa7e8ec66

View File

@@ -23,20 +23,20 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
const sendMessageAck = async({ attrs }: BinaryNode, includeType: boolean) => { const sendMessageAck = async({ attrs }: BinaryNode, includeType: boolean) => {
const isGroup = !!attrs.participant const isGroup = !!attrs.participant
const { user: meUser } = jidDecode(authState.creds.me!.id!) const meJid = authState.creds.me!.id!
const stanza: BinaryNode = { const stanza: BinaryNode = {
tag: 'ack', tag: 'ack',
attrs: { attrs: {
class: 'receipt', class: 'receipt',
id: attrs.id, id: attrs.id,
to: isGroup ? attrs.from : authState.creds.me!.id, to: attrs.from,
} }
} }
if(includeType) { if(includeType) {
stanza.attrs.type = attrs.type stanza.attrs.type = attrs.type
} }
if(isGroup) { if(isGroup) {
stanza.attrs.participant = jidEncode(meUser, 's.whatsapp.net') stanza.attrs.participant = jidNormalizedUser(meJid)
} }
logger.debug({ attrs: stanza.attrs }, 'sent message ack') logger.debug({ attrs: stanza.attrs }, 'sent message ack')
await sendNode(stanza) await sendNode(stanza)
@@ -513,5 +513,5 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
} }
}) })
return { ...sock, processMessage } return { ...sock, processMessage, sendMessageAck }
} }