Skip to content

Commit

Permalink
feat: Added type definitions for incoming calls (#2211)
Browse files Browse the repository at this point in the history
  • Loading branch information
gekkedev authored Jun 18, 2024
1 parent 11210b3 commit b88c9db
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
13 changes: 6 additions & 7 deletions src/api/layers/listener.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
ParticipantEvent,
PresenceEvent,
Wid,
IncomingCall,
} from '../model';
import { MessageType, SocketState, SocketStream } from '../model/enum';
import { InterfaceMode } from '../model/enum/interface-mode';
Expand Down Expand Up @@ -501,18 +502,16 @@ export class ListenerLayer extends ProfileLayer {
}

/**
* @event Escuta por ligações recebidas, seja de áudio ou vídeo.
*
* Para recusar a ligação, basta chamar o `rejectCall` {@link rejectCall}
*
* @returns Objeto descartável para parar de ouvir
* @event Listen for incoming calls, whether audio or video (pending a reaction).
* To reject the call, simply call `rejectCall` {@link rejectCall}
* @returns Disposable object to stop listening
*/
public onIncomingCall(callback: (call: any) => any) {
public onIncomingCall(callback: (call: IncomingCall) => any) {
return this.registerEvent('onIncomingCall', callback);
}

/**
* Listens to presence changed, by default, it will triggered for active chats only or contacts subscribed (see {@link subscribePresence})
* Listens to presence changed, by default, it will be triggered for active chats only or contacts subscribed (see {@link subscribePresence})
* @event Listens to presence changed
* @param callback Callback of on presence changed
* @returns Disposable object to stop the listening
Expand Down
4 changes: 2 additions & 2 deletions src/api/model/contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ export interface Contact {
msgs: any;

/**
* Name of concat in your agenda
* Name of the contact in your agenda
*/
name?: string;
plaintextDisabled: boolean;

/**
* @deprecated Depreciado em favor da função {@link getProfilePicFromServer}
* @deprecated Deprecated in favor of the function `getProfilePicFromServer` {@link getProfilePicFromServer}
*/
profilePicThumbObj: ProfilePicThumbObj;

Expand Down
34 changes: 34 additions & 0 deletions src/api/model/incoming-call.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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/>.
*/

export interface IncomingCall {
/** alphanumeric ID of the call, can e.g. usable for hanging up */
id: string;
/** ID of the caller, can be used to message them directly */
peerJid: string;
/** Epoch timestamp (seconds) */
offerTime: number;
isVideo: boolean;
isGroup: boolean;
groupJid: string | null;
canHandleLocally: boolean;
outgoing: boolean;
isSilenced: boolean;
offerReceivedWhileOffline: boolean;
webClientShouldHandle: boolean;
participants: any[];
}
1 change: 1 addition & 0 deletions src/api/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export { LiveLocation } from './live-location';
export { ContactStatus } from './contact-status';
export { GroupCreation } from './group-creation';
export { WhatsappProfile } from './whatsapp-profile';
export { IncomingCall } from './incoming-call';
export * from './result';
export * from './get-messages-param';
export * from './initializer';
Expand Down

0 comments on commit b88c9db

Please sign in to comment.