mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-18 03:29:14 +00:00
76 lines
1.7 KiB
JavaScript
76 lines
1.7 KiB
JavaScript
'use strict';
|
|
|
|
const Base = require('./Base');
|
|
|
|
/**
|
|
* Represents a Call on WhatsApp
|
|
* @extends {Base}
|
|
*/
|
|
class Call extends Base {
|
|
constructor(client, data) {
|
|
super(client);
|
|
|
|
if (data) this._patch(data);
|
|
}
|
|
|
|
_patch(data) {
|
|
/**
|
|
* Call ID
|
|
* @type {string}
|
|
*/
|
|
this.id = data.id;
|
|
/**
|
|
* From
|
|
* @type {string}
|
|
*/
|
|
this.from = data.peerJid;
|
|
/**
|
|
* Unix timestamp for when the call was created
|
|
* @type {number}
|
|
*/
|
|
this.timestamp = data.offerTime;
|
|
/**
|
|
* Is video
|
|
* @type {boolean}
|
|
*/
|
|
this.isVideo = data.isVideo;
|
|
/**
|
|
* Is Group
|
|
* @type {boolean}
|
|
*/
|
|
this.isGroup = data.isGroup;
|
|
/**
|
|
* Indicates if the call was sent by the current user
|
|
* @type {boolean}
|
|
*/
|
|
this.fromMe = data.outgoing;
|
|
/**
|
|
* Indicates if the call can be handled in waweb
|
|
* @type {boolean}
|
|
*/
|
|
this.canHandleLocally = data.canHandleLocally;
|
|
/**
|
|
* Indicates if the call Should be handled in waweb
|
|
* @type {boolean}
|
|
*/
|
|
this.webClientShouldHandle = data.webClientShouldHandle;
|
|
/**
|
|
* Object with participants
|
|
* @type {object}
|
|
*/
|
|
this.participants = data.participants;
|
|
|
|
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; |