diff --git a/src/structures/Contact.js b/src/structures/Contact.js index 38f88da..4ee5194 100644 --- a/src/structures/Contact.js +++ b/src/structures/Contact.js @@ -155,10 +155,18 @@ class Contact extends Base { if (this.isGroup) return false; await this.client.pupPage.evaluate(async (contactId) => { - const chat = await window.WWebJS.getChat(contactId); + const contact = await window + .require('WAWebCollections') + .Contact.find(contactId); + const resolved = window + .require('WAWebBlockContactUtils') + .getContactToBlockOnlyUseIfNoAssociatedChat( + contact, + 'ChatListBlock', + ); await window .require('WAWebBlockContactAction') - .blockContact({ contact: chat }); + .blockContact({ contact: resolved }); }, this.id._serialized); this.isBlocked = true; @@ -173,12 +181,18 @@ class Contact extends Base { if (this.isGroup) return false; await this.client.pupPage.evaluate(async (contactId) => { - const contact = window + const contact = await window .require('WAWebCollections') - .Contact.get(contactId); + .Contact.find(contactId); + const resolved = window + .require('WAWebBlockContactUtils') + .getContactToBlockOnlyUseIfNoAssociatedChat( + contact, + 'ChatListBlock', + ); await window .require('WAWebBlockContactAction') - .unblockContact(contact); + .unblockContact(resolved); }, this.id._serialized); this.isBlocked = false; diff --git a/src/util/Injected/Utils.js b/src/util/Injected/Utils.js index ab9bb04..547f917 100644 --- a/src/util/Injected/Utils.js +++ b/src/util/Injected/Utils.js @@ -1023,6 +1023,20 @@ exports.LoadUtils = () => { } res.isBlocked = contact.isContactBlocked; + if (!res.isBlocked) { + const alt = window + .require('WAWebApiContact') + .getAlternateUserWid( + window + .require('WAWebWidFactory') + .asUserWidOrThrow(contact.id), + ); + if (alt) { + res.isBlocked = !!window + .require('WAWebCollections') + .Blocklist.get(alt); + } + } const ContactMethods = window.require('WAWebContactGetters'); res.isMe = ContactMethods.getIsMe(contact);