diff --git a/index.d.ts b/index.d.ts index 76ac264..4da695e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1326,6 +1326,9 @@ declare namespace WAWebJS { webClientShouldHandle: boolean, /** Object with participants */ participants: object + + /** Reject the call */ + reject: () => Promise } /** Message type List */ diff --git a/src/structures/Call.js b/src/structures/Call.js index 1e6644d..0e48989 100644 --- a/src/structures/Call.js +++ b/src/structures/Call.js @@ -62,7 +62,15 @@ class Call extends Base { return super._patch(data); } - + + /** + * Reject the call + */ + async reject() { + return this.client.pupPage.evaluate((peerJid, id) => { + return window.WWebJS.rejectCall(peerJid, id); + }, this.from, this.id); + } } module.exports = Call; \ No newline at end of file diff --git a/src/util/Injected.js b/src/util/Injected.js index 7ece210..a0a7b12 100644 --- a/src/util/Injected.js +++ b/src/util/Injected.js @@ -53,6 +53,8 @@ exports.ExposeStore = (moduleRaidStr) => { window.Store.ReplyUtils = window.mR.findModule('canReplyMsg').length > 0 && window.mR.findModule('canReplyMsg')[0]; window.Store.MsgActionChecks = window.mR.findModule('canSenderRevokeMsg')[0]; window.Store.QuotedMsg = window.mR.findModule('getQuotedMsgObj')[0]; + window.Store.Socket = window.mR.findModule('deprecatedSendIq')[0]; + window.Store.SocketWap = window.mR.findModule('wap')[0]; window.Store.StickerTools = { ...window.mR.findModule('toWebpSticker')[0], ...window.mR.findModule('addWebpMetadata')[0] @@ -602,4 +604,21 @@ exports.LoadUtils = () => { return undefined; }; + + window.WWebJS.rejectCall = async (peerJid, id) => { + peerJid = peerJid.split('@')[0] + '@s.whatsapp.net'; + let userId = window.Store.User.getMaybeMeUser().user + '@s.whatsapp.net'; + const stanza = window.Store.SocketWap.wap('call', { + id: window.Store.SocketWap.generateId(), + from: window.Store.SocketWap.USER_JID(userId), + to: window.Store.SocketWap.USER_JID(peerJid), + }, [ + window.Store.SocketWap.wap('reject', { + 'call-id': id, + 'call-creator': window.Store.SocketWap.USER_JID(peerJid), + count: '0', + }) + ]); + await window.Store.Socket.deprecatedCastStanza(stanza); + }; };