Compare commits

..

1 Commits

Author SHA1 Message Date
dependabot[bot]
1499ea503e chore(deps): bump node-fetch from 2.6.7 to 3.3.0
Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.7 to 3.3.0.
- [Release notes](https://github.com/node-fetch/node-fetch/releases)
- [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.7...v3.3.0)

---
updated-dependencies:
- dependency-name: node-fetch
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-26 09:28:42 +00:00
6 changed files with 39 additions and 82 deletions

7
index.d.ts vendored
View File

@@ -1108,11 +1108,11 @@ declare namespace WAWebJS {
/** Promotes or demotes participants by IDs to regular users or admins */
export type ChangeParticipantsPermissions =
(participantIds: Array<string>, sleep?: number) => Promise<{ status: number }>
(participantIds: Array<string>) => Promise<{ status: number }>
/** Adds or removes a list of participants by ID to the group */
export type ChangeGroupParticipants =
(participantIds: Array<string>, sleep?: number) => Promise<{
(participantIds: Array<string>) => Promise<{
status: number;
participants: Array<{
[key: string]: {
@@ -1326,9 +1326,6 @@ declare namespace WAWebJS {
webClientShouldHandle: boolean,
/** Object with participants */
participants: object
/** Reject the call */
reject: () => Promise<void>
}
/** Message type List */

View File

@@ -33,7 +33,7 @@
"fluent-ffmpeg": "^2.1.2",
"jsqr": "^1.3.1",
"mime": "^3.0.0",
"node-fetch": "^2.6.5",
"node-fetch": "^3.3.0",
"node-webpmux": "^3.1.0",
"puppeteer": "^13.0.0"
},

View File

@@ -62,15 +62,7 @@ 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;

View File

@@ -1,7 +1,6 @@
'use strict';
const Chat = require('./Chat');
const Util = require('../util/Util');
/**
* Group participant information
@@ -53,65 +52,57 @@ class GroupChat extends Chat {
get participants() {
return this.groupMetadata.participants;
}
/**
* Internal function to change a number of participant's state..
* @param {string} type (promote|demote|add|remove)
*/
async _changeParticipants(participantIds, type, sleep = null) {
return await this.client.pupPage.evaluate(async (chatId, participantIds, type, sleep) => {
if (type != 'add' && type != 'remove' && type != 'promote' && type != 'demote') return null;
const chatWid = window.Store.WidFactory.createWid(chatId);
const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p));
const status = [];
for (const participantWid of participantWids) {
status.push(await window.Store.GroupParticipants['send'+type.charAt(0).toUpperCase() + type.slice(1)+'Participants'](chatWid, [participantWid]));
if (sleep) {
await Util.sleep(sleep);
}
}
return status;
}, this.id._serialized, participantIds, type, sleep);
}
/**
* Adds a list of participants by ID to the group
* @param {Array<string>} participantIds
* @param {?number} default 100ms, amount to sleep in milliseconds before adding the next participant
* @returns {Promise<Array<Object>>}
* @param {Array<string>} participantIds
* @returns {Promise<Object>}
*/
async addParticipants(participantIds, sleep = 100) {
return this._changeParticipants(participantIds, 'add', sleep);
async addParticipants(participantIds) {
return await this.client.pupPage.evaluate((chatId, participantIds) => {
const chatWid = window.Store.WidFactory.createWid(chatId);
const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p));
return window.Store.GroupParticipants.sendAddParticipants(chatWid, participantWids);
}, this.id._serialized, participantIds);
}
/**
* Removes a list of participants by ID to the group
* @param {Array<string>} participantIds
* @param {?number} default 100ms, amount to sleep in milliseconds before removing the next participant
* @returns {Promise<Array<Object>>}
* @param {Array<string>} participantIds
* @returns {Promise<Object>}
*/
async removeParticipants(participantIds, sleep = 100) {
return this._changeParticipants(participantIds, 'remove', sleep);
async removeParticipants(participantIds) {
return await this.client.pupPage.evaluate((chatId, participantIds) => {
const chatWid = window.Store.WidFactory.createWid(chatId);
const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p));
return window.Store.GroupParticipants.sendRemoveParticipants(chatWid, participantWids);
}, this.id._serialized, participantIds);
}
/**
* Promote participants to admins by IDs
* @param {Array<string>} participantIds
* @param {?number} default 100ms, amount to sleep in milliseconds before promoting the next participant
* @returns {Promise<Array<Object>>}
* Promotes participants by IDs to admins
* @param {Array<string>} participantIds
* @returns {Promise<{ status: number }>} Object with status code indicating if the operation was successful
*/
async promoteParticipants(participantIds, sleep = 100) {
return this._changeParticipants(participantIds, 'promote', sleep);
async promoteParticipants(participantIds) {
return await this.client.pupPage.evaluate((chatId, participantIds) => {
const chatWid = window.Store.WidFactory.createWid(chatId);
const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p));
return window.Store.GroupParticipants.sendPromoteParticipants(chatWid, participantWids);
}, this.id._serialized, participantIds);
}
/**
* Demotes admins to regular participants by IDs
* @param {Array<string>} participantIds
* @param {?number} default 100ms, amount to sleep in milliseconds before demoting the next participant
* @returns {Promise<Array<Object>>}
* Demotes participants by IDs to regular users
* @param {Array<string>} participantIds
* @returns {Promise<{ status: number }>} Object with status code indicating if the operation was successful
*/
async demoteParticipants(participantIds, sleep = 100) {
return this._changeParticipants(participantIds, 'demote', sleep);
async demoteParticipants(participantIds) {
return await this.client.pupPage.evaluate((chatId, participantIds) => {
const chatWid = window.Store.WidFactory.createWid(chatId);
const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p));
return window.Store.GroupParticipants.sendDemoteParticipants(chatWid, participantWids);
}, this.id._serialized, participantIds);
}
/**
@@ -240,4 +231,4 @@ class GroupChat extends Chat {
}
module.exports = GroupChat;
module.exports = GroupChat;

View File

@@ -53,8 +53,6 @@ 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]
@@ -604,21 +602,4 @@ 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);
};
};

View File

@@ -181,10 +181,6 @@ class Util {
static setFfmpegPath(path) {
ffmpeg.setFfmpegPath(path);
}
static sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
}
module.exports = Util;