UNPKG

@whiskeysockets/baileys

Version:

A WebSockets library for interacting with WhatsApp Web

38 lines 1.11 kB
/** * Builds an ACK stanza for a received node. * Pure function -- no I/O, no side effects. * * Mirrors WhatsApp Web's ACK construction: * - WAWebHandleMsgSendAck.sendAck / sendNack * - WAWebCreateNackFromStanza.createNackFromStanza */ export function buildAckStanza(node, errorCode, meId) { const { tag, attrs } = node; const stanza = { tag: 'ack', attrs: { id: attrs.id, to: attrs.from, class: tag } }; if (errorCode) { stanza.attrs.error = errorCode.toString(); } if (attrs.participant) { stanza.attrs.participant = attrs.participant; } if (attrs.recipient) { stanza.attrs.recipient = attrs.recipient; } // WA Web always includes type when present: `n.type || DROP_ATTR` if (attrs.type) { stanza.attrs.type = attrs.type; } // WA Web WAWebHandleMsgSendAck.sendAck/sendNack always include `from` for message-class ACKs if (tag === 'message' && meId) { stanza.attrs.from = meId; } return stanza; } //# sourceMappingURL=stanza-ack.js.map