curl -X POST "http://localhost:5001/channel/whitelist_add" \
-H "Content-Type: application/json" \
-d '{
"channel_id": "group123",
"channel_type": 2,
"uids": ["user456", "user789"]
}'
const response = await fetch('http://localhost:5001/channel/whitelist_add', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
channel_id: 'group123',
channel_type: 2,
uids: ['user456', 'user789']
})
});
const data = await response.json();
console.log(data);
import requests
data = {
"channel_id": "group123",
"channel_type": 2,
"uids": ["user456", "user789"]
}
response = requests.post('http://localhost:5001/channel/whitelist_add', json=data)
result = response.json()
print(result)
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
data := map[string]interface{}{
"channel_id": "group123",
"channel_type": 2,
"uids": []string{"user456", "user789"},
}
jsonData, _ := json.Marshal(data)
resp, err := http.Post(
"http://localhost:5001/channel/whitelist_add",
"application/json",
bytes.NewBuffer(jsonData),
)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
{
"status": "ok"
}
频道管理
添加频道白名单
将用户添加到频道白名单
POST
/
channel
/
whitelist_add
curl -X POST "http://localhost:5001/channel/whitelist_add" \
-H "Content-Type: application/json" \
-d '{
"channel_id": "group123",
"channel_type": 2,
"uids": ["user456", "user789"]
}'
const response = await fetch('http://localhost:5001/channel/whitelist_add', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
channel_id: 'group123',
channel_type: 2,
uids: ['user456', 'user789']
})
});
const data = await response.json();
console.log(data);
import requests
data = {
"channel_id": "group123",
"channel_type": 2,
"uids": ["user456", "user789"]
}
response = requests.post('http://localhost:5001/channel/whitelist_add', json=data)
result = response.json()
print(result)
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
data := map[string]interface{}{
"channel_id": "group123",
"channel_type": 2,
"uids": []string{"user456", "user789"},
}
jsonData, _ := json.Marshal(data)
resp, err := http.Post(
"http://localhost:5001/channel/whitelist_add",
"application/json",
bytes.NewBuffer(jsonData),
)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
{
"status": "ok"
}
概述
将用户添加到频道白名单,白名单用户拥有特殊权限,可以绕过某些限制。请求体
必传参数
频道 ID
频道类型
1- 个人频道2- 群组频道
curl -X POST "http://localhost:5001/channel/whitelist_add" \
-H "Content-Type: application/json" \
-d '{
"channel_id": "group123",
"channel_type": 2,
"uids": ["user456", "user789"]
}'
const response = await fetch('http://localhost:5001/channel/whitelist_add', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
channel_id: 'group123',
channel_type: 2,
uids: ['user456', 'user789']
})
});
const data = await response.json();
console.log(data);
import requests
data = {
"channel_id": "group123",
"channel_type": 2,
"uids": ["user456", "user789"]
}
response = requests.post('http://localhost:5001/channel/whitelist_add', json=data)
result = response.json()
print(result)
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
data := map[string]interface{}{
"channel_id": "group123",
"channel_type": 2,
"uids": []string{"user456", "user789"},
}
jsonData, _ := json.Marshal(data)
resp, err := http.Post(
"http://localhost:5001/channel/whitelist_add",
"application/json",
bytes.NewBuffer(jsonData),
)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
{
"status": "ok"
}
响应字段
操作状态,成功时返回
"ok"状态码
| 状态码 | 说明 |
|---|---|
| 200 | 白名单操作成功 |
| 400 | 请求参数错误 |
| 403 | 没有管理权限 |
| 404 | 频道不存在 |
| 500 | 服务器内部错误 |
白名单机制
特殊权限
白名单用户享有以下特殊权限:| 权限 | 说明 | 适用场景 |
|---|---|---|
| 绕过禁言 | 在全员禁言时仍可发言 | 管理员、重要用户 |
权限层级
白名单在权限体系中的位置:- 管理员权限 > 白名单 > 普通成员权限
- 黑名单 > 白名单(黑名单优先级更高)
- 系统用户 > 白名单
使用场景
白名单与黑名单的关系
优先级规则
黑名单 > 白名单 > 普通权限
冲突处理
| 情况 | 结果 | 说明 |
|---|---|---|
| 同时在黑白名单 | 按黑名单处理 | 黑名单优先级更高 |
| 只在白名单 | 享受白名单权限 | 正常白名单用户 |
| 只在黑名单 | 受黑名单限制 | 正常黑名单用户 |
| 都不在名单 | 普通用户权限 | 按默认权限处理 |
⌘I

