fix: use WA's own LID resolution for block/unblock (#201671)
* fix: use WA's own LID resolution for block/unblock block() was passing a Chat object to blockContact() which expects a contact. unblock() was using synchronous Contact.get() which returns undefined if the contact isn't cached. with blocklist migration enabled, blocking a PN contact without a chat fails because the internal S() function needs a LID or an existing chat to resolve the accountLid. The old getChat() approach worked around this by creating a chat via findOrCreateLatestChat, but that's a side effect and passes the wrong type. use WAWebBlockContactUtils.getContactToBlockOnlyUseIfNoAssociatedChat() instead, which is WA's own utility for this exact case. It resolves the contact's LID via getCurrentLidContact() without needing to create a chat. * fix: check alternate WID for blocked status in getContactModel iscontactblocked on PN contacts returns false because the Blocklist only contains LID entries. Use getAlternateUserWid() to resolve the PN/LID mapping and check the Blocklist directly, matching WA web's own $Contact$p_3 fallback logic. --------- Co-authored-by: BenyFilho <168232825+BenyFilho@users.noreply.github.com>
This commit is contained in:
parent
51f5920153
commit
016a56bb56
1 changed files with 33 additions and 5 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue