Skip to content

Commit

Permalink
fix: Fixed WPP.blocklist.isBlocked (fix #1231)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Jul 26, 2023
1 parent b7c4c98 commit 353a3c2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/blocklist/functions/blockContact.ts
Expand Up @@ -21,6 +21,7 @@ import { ContactModel, ContactStore, Wid } from '../../whatsapp';
import { SANITIZED_VERSION_STR } from '../../whatsapp/contants';
import * as wa_functions from '../../whatsapp/functions';
import { BlocklistResult } from '../types';
import { isBlocked } from './isBlocked';

export async function blockContact(
chatId: string | Wid
Expand All @@ -41,6 +42,6 @@ export async function blockContact(

return {
wid,
isBlocked: contact.isBlocked(),
isBlocked: isBlocked(wid),
};
}
6 changes: 3 additions & 3 deletions src/blocklist/functions/isBlocked.ts
Expand Up @@ -15,12 +15,12 @@
*/

import { assertWid } from '../../assert';
import { ContactModel, ContactStore, Wid } from '../../whatsapp';
import { BlocklistStore, Wid } from '../../whatsapp';

export function isBlocked(chatId: string | Wid): boolean {
const wid = assertWid(chatId);

const contact = ContactStore.get(wid) || new ContactModel({ id: wid });
const contact = BlocklistStore.get(wid);

return contact.isBlocked();
return !!contact;
}
3 changes: 2 additions & 1 deletion src/blocklist/functions/unblockContact.ts
Expand Up @@ -18,6 +18,7 @@ import { assertWid } from '../../assert';
import { ContactModel, ContactStore, Wid } from '../../whatsapp';
import * as wa_functions from '../../whatsapp/functions';
import { BlocklistResult } from '../types';
import { isBlocked } from './isBlocked';

export async function unblockContact(
chatId: string | Wid
Expand All @@ -30,6 +31,6 @@ export async function unblockContact(

return {
wid,
isBlocked: contact.isBlocked(),
isBlocked: isBlocked(wid),
};
}

0 comments on commit 353a3c2

Please sign in to comment.