Skip to content

Commit

Permalink
feat: Added outgoing_call event
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelo386 committed Jun 17, 2024
1 parent 0ee81af commit c1a65cc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/call/events/eventTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ export interface CallEventTypes {
peerJid: Wid;
};
/**
* Triggered when you a outcoming call
* Triggered when you a outgoing call
*
* @example
* ```javascript
* WPP.on('call.outcoming_call', (call) => {
* WPP.on('call.outgoing_call', (call) => {
* // Your code
* //Example: End any outcoming call
* //Example: End any outgoing call
* WPP.call.endCall(call.id);
* });
* ```
*/
'call.outcoming_call': {
'call.outgoing_call': {
/**
* The call id
*/
Expand Down
2 changes: 1 addition & 1 deletion src/call/events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
*/

import './registerIncomingCallEvent';
import './registerOutcomingCallEvent';
import './registerOutgoingCallEvent';
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ webpack.onInjected(() => register());
function register() {
CallStore.on('add', (call: CallModel) => {
if (call.isGroup) {
internalEv.emit('call.outcoming_call', {
internalEv.emit('call.outgoing_call', {
id: call.id,
isGroup: call.isGroup,
isVideo: call.isVideo,
Expand All @@ -37,7 +37,7 @@ function register() {

CallStore.on('change', (call: CallModel) => {
if (call.getState() === CALL_STATES.OUTGOING_RING) {
internalEv.emit('call.outcoming_call', {
internalEv.emit('call.outgoing_call', {
id: call.id,
isGroup: call.isGroup,
isVideo: call.isVideo,
Expand Down
16 changes: 8 additions & 8 deletions src/call/functions/end.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2023 WPPConnect Team
* Copyright 2024 WPPConnect Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,18 +19,18 @@ import { CallModel, CallStore, websocket } from '../../whatsapp';
import { CALL_STATES } from '../../whatsapp/enums';

/**
* End a outcoming call
* End a outgoing call
*
* @example
* ```javascript
* // End any outcoming call
* // End any outgoing call
* WPP.call.end();
*
* // End specific call id
* WPP.call.end(callId);
*
* // End any outcoming call
* WPP.on('call.outcoming_call', (call) => {
* // End any outgoing call
* WPP.on('call.outgoing_call', (call) => {
* WPP.call.end(call.id);
* });
* ```
Expand All @@ -50,7 +50,7 @@ export async function end(callId?: string): Promise<boolean> {
if (callId) {
call = CallStore.get(callId);
} else {
// First outcoming ring or call group
// First outgoing ring or call group
call = CallStore.findFirst(
(c) => callOut.includes(c.getState()) || c.isGroup
);
Expand All @@ -68,8 +68,8 @@ export async function end(callId?: string): Promise<boolean> {

if (!callOut.includes(call.getState()) && !call.isGroup) {
throw new WPPError(
'call_is_not_outcoming_calling',
`Call ${callId || '<empty>'} is not outcoming calling`,
'call_is_not_outgoing_calling',
`Call ${callId || '<empty>'} is not outgoing calling`,
{
callId,
state: call.getState(),
Expand Down

0 comments on commit c1a65cc

Please sign in to comment.