mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-18 03:29:14 +00:00
Add getBlockedContacts method (#770)
* add simple method to get blocked ids * Change getBlockedList to getBlockedIds * getBlockedIds to getBlockedContacts * typo * ESLint & other changes * 🏷️ types * fix: no `this.client` * add tests Co-authored-by: Rajeh Taher <rajeh@reforward.dev> Co-authored-by: Pedro Lopez <pedroslopez@me.com> Co-authored-by: Pedro S. Lopez <pslamoros@hotmail.com>
This commit is contained in:
committed by
GitHub
parent
95facee885
commit
4338664590
@@ -946,6 +946,19 @@ class Client extends EventEmitter {
|
||||
|
||||
return Promise.all(chatIds.map(id => this.getChatById(id)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all blocked contacts by host account
|
||||
* @returns {Promise<Array<Contact>>}
|
||||
*/
|
||||
async getBlockedContacts() {
|
||||
const blockedContacts = await this.pupPage.evaluate(() => {
|
||||
let chatIds = window.Store.Blocklist.models.map(a => a.id._serialized);
|
||||
return Promise.all(chatIds.map(id => window.WWebJS.getContact(id)));
|
||||
});
|
||||
|
||||
return blockedContacts.map(contact => ContactFactory.create(this.client, contact));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Client;
|
||||
|
||||
Reference in New Issue
Block a user