Merge branch 'main' into dependabot/npm_and_yarn/sinon-14.0.0

This commit is contained in:
Rajeh Taher
2022-10-10 01:53:35 +03:00
committed by GitHub
4 changed files with 17 additions and 11 deletions

10
index.d.ts vendored
View File

@@ -1,7 +1,7 @@
import { EventEmitter } from 'events' import { EventEmitter } from 'events'
import { RequestInit } from 'node-fetch' import { RequestInit } from 'node-fetch'
import puppeteer from 'puppeteer' import * as puppeteer from 'puppeteer'
declare namespace WAWebJS { declare namespace WAWebJS {
@@ -399,10 +399,10 @@ declare namespace WAWebJS {
* Remote store interface * Remote store interface
*/ */
export interface Store { export interface Store {
sessionExists: ({session: string}) => Promise<boolean> | boolean, sessionExists: (options: { session: string }) => Promise<boolean> | boolean,
delete: ({session: string}) => Promise<any> | any, delete: (options: { session: string }) => Promise<any> | any,
save: ({session: string}) => Promise<any> | any, save: (options: { session: string }) => Promise<any> | any,
extract: ({session: string, path: string}) => Promise<any> | any, extract: (options: { session: string, path: string }) => Promise<any> | any,
} }
/** /**

View File

@@ -989,7 +989,13 @@ class Client extends EventEmitter {
*/ */
async getCommonGroups(contactId) { async getCommonGroups(contactId) {
const commonGroups = await this.pupPage.evaluate(async (contactId) => { const commonGroups = await this.pupPage.evaluate(async (contactId) => {
const contact = window.Store.Contact.get(contactId); let contact = window.Store.Contact.get(contactId);
if (!contact) {
const wid = window.Store.WidFactory.createUserWid(contactId);
const chatConstructor = window.Store.Contact.getModelsArray().find(c=>!c.isGroup).constructor;
contact = new chatConstructor({id: wid});
}
if (contact.commonGroups) { if (contact.commonGroups) {
return contact.commonGroups.serialize(); return contact.commonGroups.serialize();
} }

View File

@@ -178,9 +178,9 @@ class RemoteAuth extends BaseAuthStrategy {
await fs.promises.rm(dirElement, { await fs.promises.rm(dirElement, {
recursive: true, recursive: true,
force: true force: true
}); }).catch(() => {});
} else { } else {
await fs.promises.unlink(dirElement); await fs.promises.unlink(dirElement).catch(() => {});
} }
} }
} }

View File

@@ -430,14 +430,14 @@ class Message extends Base {
/** /**
* Deletes a message from the chat * Deletes a message from the chat
* @param {?boolean} everyone If true and the message is sent by the current user, will delete it for everyone in the chat. * @param {?boolean} everyone If true and the message is sent by the current user or the user is an admin, will delete it for everyone in the chat.
*/ */
async delete(everyone) { async delete(everyone) {
await this.client.pupPage.evaluate((msgId, everyone) => { await this.client.pupPage.evaluate((msgId, everyone) => {
let msg = window.Store.Msg.get(msgId); let msg = window.Store.Msg.get(msgId);
if (everyone && msg.id.fromMe && msg._canRevoke()) { if (everyone && msg._canRevoke()) {
return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], {type: 'Sender'}); return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], { type: msg.id.fromMe ? 'Sender' : 'Admin' });
} }
return window.Store.Cmd.sendDeleteMsgs(msg.chat, [msg], true); return window.Store.Cmd.sendDeleteMsgs(msg.chat, [msg], true);