From 705d4d31fdbfcfdc4a1f997c2864ce23176419ef Mon Sep 17 00:00:00 2001 From: Shir Serlui <70711723+shirser121@users.noreply.github.com> Date: Thu, 18 Aug 2022 19:20:30 +0300 Subject: [PATCH 1/4] Use getCommonGroups not contact (#1623) --- src/Client.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Client.js b/src/Client.js index b36eb96..d3c9bb4 100644 --- a/src/Client.js +++ b/src/Client.js @@ -989,7 +989,13 @@ class Client extends EventEmitter { */ async getCommonGroups(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) { return contact.commonGroups.serialize(); } From 62623347e8bcb23ba62ea43d36048b77cee10821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=BC=BA=20L=E1=B4=87G=CC=B8=E1=B4=87=C9=B4D=20=E0=BC=BB?= <39593002+jtourisNS@users.noreply.github.com> Date: Thu, 18 Aug 2022 14:26:46 -0300 Subject: [PATCH 2/4] [Update] - adding catch block on promise for windows error (#1659) --- src/authStrategies/RemoteAuth.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/authStrategies/RemoteAuth.js b/src/authStrategies/RemoteAuth.js index 5ae85cc..f84ba59 100644 --- a/src/authStrategies/RemoteAuth.js +++ b/src/authStrategies/RemoteAuth.js @@ -178,9 +178,9 @@ class RemoteAuth extends BaseAuthStrategy { await fs.promises.rm(dirElement, { recursive: true, force: true - }); + }).catch(() => {}); } else { - await fs.promises.unlink(dirElement); + await fs.promises.unlink(dirElement).catch(() => {}); } } } From b1e0fce5048c51a1c15b20d0e03845190d04d971 Mon Sep 17 00:00:00 2001 From: blox <73058244+soudblox@users.noreply.github.com> Date: Mon, 19 Sep 2022 02:33:43 +0700 Subject: [PATCH 3/4] Allow the deletion of others' messages (#1688) --- src/structures/Message.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/structures/Message.js b/src/structures/Message.js index dc4acaf..e8260dd 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -430,14 +430,14 @@ class Message extends Base { /** * 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) { await this.client.pupPage.evaluate((msgId, everyone) => { let msg = window.Store.Msg.get(msgId); - if (everyone && msg.id.fromMe && msg._canRevoke()) { - return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], {type: 'Sender'}); + if (everyone && msg._canRevoke()) { + return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], { type: msg.id.fromMe ? 'Sender' : 'Admin' }); } return window.Store.Cmd.sendDeleteMsgs(msg.chat, [msg], true); From 55f75b8f69eaf2bd2b35c634cd6ffc29956297b8 Mon Sep 17 00:00:00 2001 From: stefanfuchs Date: Tue, 4 Oct 2022 09:24:03 -0300 Subject: [PATCH 4/4] fix: typescript compilation (#1693) Co-authored-by: Rajeh Taher --- index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.d.ts b/index.d.ts index edf4684..76ac264 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,7 +1,7 @@ import { EventEmitter } from 'events' import { RequestInit } from 'node-fetch' -import puppeteer from 'puppeteer' +import * as puppeteer from 'puppeteer' declare namespace WAWebJS { @@ -399,10 +399,10 @@ declare namespace WAWebJS { * Remote store interface */ export interface Store { - sessionExists: ({session: string}) => Promise | boolean, - delete: ({session: string}) => Promise | any, - save: ({session: string}) => Promise | any, - extract: ({session: string, path: string}) => Promise | any, + sessionExists: (options: { session: string }) => Promise | boolean, + delete: (options: { session: string }) => Promise | any, + save: (options: { session: string }) => Promise | any, + extract: (options: { session: string, path: string }) => Promise | any, } /**