From 749e293c6c84af53485c7517387c08199579ef6c Mon Sep 17 00:00:00 2001 From: Rahul Kasireddy <66378906+RahulKasireddy@users.noreply.github.com> Date: Tue, 9 Aug 2022 12:05:52 +0530 Subject: [PATCH] added rejectCall function --- src/Socket/messages-recv.ts | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Socket/messages-recv.ts b/src/Socket/messages-recv.ts index 16dc5e7..161550f 100644 --- a/src/Socket/messages-recv.ts +++ b/src/Socket/messages-recv.ts @@ -64,6 +64,29 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => { logger.debug({ recv: { tag, attrs }, sent: stanza.attrs }, 'sent ack') await sendNode(stanza) } + + const rejectCall = async(call_id) => { + const stanza: BinaryNode = { + tag: 'call', + attrs: { + from: authState.creds.me.id, + to: callOfferData[call_id].from, + id: (new Date().getTime() / 1000).toString().replace('.', '-'), + }, + content: [{ + tag: 'reject', + attrs: { + 'call-id': call_id, + 'call-creator': callOfferData[call_id].from, + count: '0', + }, + content: undefined, + }], + } + + logger.debug({ call_id, caller: callOfferData[call_id].from, me: authState.creds.me.id, }, 'rejecting call') + await sendNode(stanza) + } const sendRetryRequest = async(node: BinaryNode, forceIncludeKeys = false) => { const msgId = node.attrs.id @@ -616,6 +639,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => { return { ...sock, sendMessageAck, - sendRetryRequest + sendRetryRequest, + rejectCall } -} \ No newline at end of file +}