Blocklist Management (Electron)
Supported since SDK 5.4.0. This feature is currently only available in the [Electron Solution].
After adding a user to the blocklist, you will no longer receive any one-to-one chat messages from that user.
-
Blocklisting is a one-way operation. For example: When User A blocks User B, it means B cannot send messages to A (error code
405). However, A can still send messages to B, and B will receive them normally. -
There is an upper limit to the total number of users that can be added to a single user's blocklist. For Chat Starter Plan and Chat Pro Plan, the limit is 3000 users.
-
Sending one-to-one chat messages via server API calls is not restricted by blocklists by default. To enable this restriction, set
verifyBlacklistto1when calling the API.
Add to Blocklist
Call addToBlacklist to add a user to the blocklist.
Interface
RongIMLib.addToBlacklist('<userId>')
#### Parameters
| Parameter | Type | Required | Description |
|:-------|:-- | :-- |:------|
| userId | string | Yes | User ID |
#### Example Code
```js
RongIMLib.addToBlacklist('<userId>').then(res => {
console.log(res.code)
})
## Remove from Blocklist \{#removeFromBlacklist}
Call [removeFromBlacklist](https://doc.rongcloud.cn/apidoc/im-web/latest/zh_CN/modules.html#removeFromBlacklist) to remove a user from the blocklist.
#### Interface
```js
RongIMLib.removeFromBlacklist('<userId>')
#### Parameters
| Parameter | Type | Required | Description |
|:-------|:-- | :-- |:------|
| userId | string | Yes | User ID |
#### Example Code
```js
RongIMLib.removeFromBlacklist('<userId>').then(res => {
console.log(res.code)
})
## Get Blocklist \{#getBlacklist}
Call [getBlacklist](https://doc.rongcloud.cn/apidoc/im-web/latest/zh_CN/modules.html#getBlacklist) to retrieve the blocklist.
#### Interface
```js
RongIMLib.getBlacklist()
#### Parameters
None
#### Example Code
```js
RongIMLib.getBlacklist().then(res => {
console.log(res)
})
## Check Blocklist Status \{#getBlacklistStatus}
Call [getBlacklistStatus](https://doc.rongcloud.cn/apidoc/im-web/latest/zh_CN/modules.html#getBlacklistStatus) to check if a specific user is in the blocklist.
#### Interface
```js
RongIMLib.getBlacklistStatus(userId)
#### Parameters
| Parameter | Type | Required | Description |
|:-------|:-- | :-- |:------|
| userId | string | Yes | User ID |
#### Example Code
```js
RongIMLib.getBlacklistStatus('<userId>').then(res => {
console.log(res)
})
[Electron Solution]:/web-imlib/electron/integration