-
-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adicionado recurso de recusar ligação do WhatsApp (close #299)
- Loading branch information
1 parent
54b2be7
commit e7ef0b6
Showing
7 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* This file is part of WPPConnect. | ||
* | ||
* WPPConnect is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* WPPConnect is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with WPPConnect. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
async function rejectCallByCallId(callId) { | ||
const call = await Store.Call.get(callId); | ||
|
||
if (!call) { | ||
throw { | ||
error: true, | ||
code: 'call_not_found', | ||
message: 'Call not found', | ||
}; | ||
} | ||
|
||
if (call.getState() !== 'INCOMING_RING') { | ||
throw { | ||
error: true, | ||
code: 'call_is_not_incoming_ring', | ||
message: 'Call is not incoming ring', | ||
}; | ||
} | ||
|
||
return await Store.sendCallSignalingMsg({ | ||
common: { | ||
peer_jid: call.peerJid, | ||
}, | ||
payload: [ | ||
'reject', | ||
{ | ||
'call-id': call.id, | ||
'call-creator': call.peerJid.toString({ legacy: true }), | ||
count: '0', | ||
}, | ||
null, | ||
], | ||
}); | ||
} | ||
|
||
export async function rejectCall(callId) { | ||
if (callId) { | ||
await rejectCallByCallId(callId); | ||
return 1; | ||
} | ||
|
||
const calls = Store.Call.models.filter( | ||
(c) => c.getState() === 'INCOMING_RING' | ||
); | ||
|
||
for (const call of calls) { | ||
await rejectCallByCallId(call.id).catch((e) => null); | ||
} | ||
|
||
return calls.lenth; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters