diff --git a/src/Socket/messages-recv.ts b/src/Socket/messages-recv.ts index 7080ff7..0a8f959 100644 --- a/src/Socket/messages-recv.ts +++ b/src/Socket/messages-recv.ts @@ -428,6 +428,15 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => { logger.debug({ attrs: node.attrs }, 'sending receipt for ack') }) + ws.on('CB:call', async(node: BinaryNode) => { + logger.info({ node }, 'recv call') + + const [child] = getAllBinaryNodeChildren(node) + if(child.tag === 'terminate' || child.tag === 'relaylatency') { + await sendMessageAck(node, { class: 'call', type: child.tag }) + } + }) + const handleReceipt = async(node: BinaryNode) => { const { attrs, content } = node const isRead = isReadReceipt(attrs.type) diff --git a/src/WABinary/index.ts b/src/WABinary/index.ts index 74bc259..e9d677c 100644 --- a/src/WABinary/index.ts +++ b/src/WABinary/index.ts @@ -276,6 +276,13 @@ export const getBinaryNodeChildren = ({ content }: BinaryNode, childTag: string) return [] } +export const getAllBinaryNodeChildren = ({ content }: BinaryNode) => { + if(Array.isArray(content)) { + return content + } + return [] +} + export const getBinaryNodeChild = ({ content }: BinaryNode, childTag: string) => { if(Array.isArray(content)) { return content.find(item => item.tag == childTag)