Skip to main content

Block a User

Block a user to prevent them from sending you messages:

Unblock a User

Unblock a previously blocked user:

Function Signature

The updateBlockStatus function is implemented in src/Socket/chats.ts:373-391:

Fetch Blocklist

Retrieve a list of all blocked contacts:

Blocklist Implementation

From src/Socket/chats.ts:359-371:
The function returns an array of JID strings representing all blocked users.

Complete Example

Listen for Block Status Changes

You can track block status changes through events:
Blocking a user will:
  • Prevent them from sending you messages
  • Hide your last seen, online status, and status updates from them
  • Not notify them that they’ve been blocked
Use fetchBlocklist() during initialization to sync your local blocklist state with WhatsApp servers.

Implementation Details

Both functions use WhatsApp’s blocklist XML namespace:
  • Block/Unblock: Sends an IQ query with type: 'set' and an item containing the action
  • Fetch Blocklist: Sends an IQ query with type: 'get' and parses the returned item nodes
The functions are exported from the makeChatsSocket in src/Socket/chats.ts:1225-1271.