curl -X POST "http://localhost:5001/conversation/sync" \
-H "Content-Type: application/json" \
-d '{
"uid": "user123",
"version": 1640995200000000000,
"last_msg_seqs": "user1:1:100|group1:2:200",
"msg_count": 10,
"only_unread": 0,
"exclude_channel_types": [3, 4]
}'
const response = await fetch('http://localhost:5001/conversation/sync', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
uid: 'user123',
version: 1640995200000000000,
last_msg_seqs: 'user1:1:100|group1:2:200',
msg_count: 10,
only_unread: 0,
exclude_channel_types: [3, 4]
})
});
const data = await response.json();
console.log(data);
import requests
data = {
"uid": "user123",
"version": 1640995200000000000,
"last_msg_seqs": "user1:1:100|group1:2:200",
"msg_count": 10,
"only_unread": 0,
"exclude_channel_types": [3, 4]
}
response = requests.post('http://localhost:5001/conversation/sync', json=data)
result = response.json()
print(result)
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
data := map[string]interface{}{
"uid": "user123",
"version": 1640995200000000000,
"last_msg_seqs": "user1:1:100|group1:2:200",
"msg_count": 10,
"only_unread": 0,
"exclude_channel_types": []int{3, 4},
}
jsonData, _ := json.Marshal(data)
resp, err := http.Post(
"http://localhost:5001/conversation/sync",
"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)
}
[
{
"channel_id": "group123",
"channel_type": 2,
"unread": 5,
"timestamp": 1640995200,
"last_msg_seq": 1005,
"version": 1640995200000000000,
"recents": [
{
"message_id": 123456789,
"message_seq": 1005,
"client_msg_no": "msg_123",
"from_uid": "user456",
"timestamp": 1640995200,
"payload": "SGVsbG8gV29ybGQ="
}
]
},
{
"channel_id": "private_user123_user789",
"channel_type": 1,
"unread": 2,
"timestamp": 1640995100,
"last_msg_seq": 502,
"version": 1640995100000000000,
"recents": [
{
"message_id": 123456788,
"message_seq": 502,
"client_msg_no": "msg_122",
"from_uid": "user789",
"timestamp": 1640995100,
"payload": "SGkgdGhlcmU="
}
]
}
]
会话管理
同步用户会话
同步用户的会话列表和状态
POST
/
conversation
/
sync
curl -X POST "http://localhost:5001/conversation/sync" \
-H "Content-Type: application/json" \
-d '{
"uid": "user123",
"version": 1640995200000000000,
"last_msg_seqs": "user1:1:100|group1:2:200",
"msg_count": 10,
"only_unread": 0,
"exclude_channel_types": [3, 4]
}'
const response = await fetch('http://localhost:5001/conversation/sync', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
uid: 'user123',
version: 1640995200000000000,
last_msg_seqs: 'user1:1:100|group1:2:200',
msg_count: 10,
only_unread: 0,
exclude_channel_types: [3, 4]
})
});
const data = await response.json();
console.log(data);
import requests
data = {
"uid": "user123",
"version": 1640995200000000000,
"last_msg_seqs": "user1:1:100|group1:2:200",
"msg_count": 10,
"only_unread": 0,
"exclude_channel_types": [3, 4]
}
response = requests.post('http://localhost:5001/conversation/sync', json=data)
result = response.json()
print(result)
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
data := map[string]interface{}{
"uid": "user123",
"version": 1640995200000000000,
"last_msg_seqs": "user1:1:100|group1:2:200",
"msg_count": 10,
"only_unread": 0,
"exclude_channel_types": []int{3, 4},
}
jsonData, _ := json.Marshal(data)
resp, err := http.Post(
"http://localhost:5001/conversation/sync",
"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)
}
[
{
"channel_id": "group123",
"channel_type": 2,
"unread": 5,
"timestamp": 1640995200,
"last_msg_seq": 1005,
"version": 1640995200000000000,
"recents": [
{
"message_id": 123456789,
"message_seq": 1005,
"client_msg_no": "msg_123",
"from_uid": "user456",
"timestamp": 1640995200,
"payload": "SGVsbG8gV29ybGQ="
}
]
},
{
"channel_id": "private_user123_user789",
"channel_type": 1,
"unread": 2,
"timestamp": 1640995100,
"last_msg_seq": 502,
"version": 1640995100000000000,
"recents": [
{
"message_id": 123456788,
"message_seq": 502,
"client_msg_no": "msg_122",
"from_uid": "user789",
"timestamp": 1640995100,
"payload": "SGkgdGhlcmU="
}
]
}
]
概述
同步用户的会话列表和状态,支持增量同步和全量同步。请求体
必传参数
string
必填
用户 ID
可选参数
integer
版本时间戳,用于增量同步
string
客户端最后消息序列号,格式:channelID:channelType:last_msg_seq|channelID:channelType:last_msg_seq
integer
每个会话返回的最近消息数量
integer
默认值:0
是否只返回未读会话 (1=只返回未读, 0=返回所有)
curl -X POST "http://localhost:5001/conversation/sync" \
-H "Content-Type: application/json" \
-d '{
"uid": "user123",
"version": 1640995200000000000,
"last_msg_seqs": "user1:1:100|group1:2:200",
"msg_count": 10,
"only_unread": 0,
"exclude_channel_types": [3, 4]
}'
const response = await fetch('http://localhost:5001/conversation/sync', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
uid: 'user123',
version: 1640995200000000000,
last_msg_seqs: 'user1:1:100|group1:2:200',
msg_count: 10,
only_unread: 0,
exclude_channel_types: [3, 4]
})
});
const data = await response.json();
console.log(data);
import requests
data = {
"uid": "user123",
"version": 1640995200000000000,
"last_msg_seqs": "user1:1:100|group1:2:200",
"msg_count": 10,
"only_unread": 0,
"exclude_channel_types": [3, 4]
}
response = requests.post('http://localhost:5001/conversation/sync', json=data)
result = response.json()
print(result)
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
data := map[string]interface{}{
"uid": "user123",
"version": 1640995200000000000,
"last_msg_seqs": "user1:1:100|group1:2:200",
"msg_count": 10,
"only_unread": 0,
"exclude_channel_types": []int{3, 4},
}
jsonData, _ := json.Marshal(data)
resp, err := http.Post(
"http://localhost:5001/conversation/sync",
"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)
}
[
{
"channel_id": "group123",
"channel_type": 2,
"unread": 5,
"timestamp": 1640995200,
"last_msg_seq": 1005,
"version": 1640995200000000000,
"recents": [
{
"message_id": 123456789,
"message_seq": 1005,
"client_msg_no": "msg_123",
"from_uid": "user456",
"timestamp": 1640995200,
"payload": "SGVsbG8gV29ybGQ="
}
]
},
{
"channel_id": "private_user123_user789",
"channel_type": 1,
"unread": 2,
"timestamp": 1640995100,
"last_msg_seq": 502,
"version": 1640995100000000000,
"recents": [
{
"message_id": 123456788,
"message_seq": 502,
"client_msg_no": "msg_122",
"from_uid": "user789",
"timestamp": 1640995100,
"payload": "SGkgdGhlcmU="
}
]
}
]
响应字段
响应是一个会话数组,每个会话包含以下字段:会话信息
string
必填
频道 ID
integer
必填
频道类型
1- 个人频道2- 群组频道
integer
必填
未读消息数量
integer
必填
最后消息时间戳
integer
必填
最后消息序列号
integer
必填
会话版本号(纳秒级时间戳)
消息列表
array
必填
状态码
| 状态码 | 说明 |
|---|---|
| 200 | 会话同步成功 |
| 400 | 请求参数错误 |
| 403 | 没有访问权限 |
| 500 | 服务器内部错误 |
参数说明
消息数量 (msg_count)
控制每个会话返回的消息数量:| 值 | 说明 | 适用场景 |
|---|---|---|
| 0 | 不返回消息 | 只需要会话列表 |
| 1-50 | 返回指定数量 | 正常使用 |
| > 50 | 系统限制为 50 | 避免数据过大 |
⌘I

