Skip to content

Commit 68e6019

Browse files
committed
Merge branch 'doc' of github.com:easemob/shengwang-chat-doc into doc
2 parents d5d050e + 5505336 commit 68e6019

File tree

9 files changed

+832
-376
lines changed

9 files changed

+832
-376
lines changed
-84.6 KB
Binary file not shown.

docs/.vuepress/sidebar/document.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,13 @@ const documentSidebar = [
381381
{ text: '发送单聊消息', link: 'message_single.html' },
382382
{ text: '发送群聊消息', link: 'message_group.html' },
383383
{ text: '发送聊天室消息', link: 'message_chatroom.html' },
384+
{ text: '发送全局广播消息', link: 'message_broadcast.html' },
384385
{ text: '上传和下载文件', link: 'message_download.html' },
385386
{ text: '获取历史消息记录', link: 'message_historical.html' },
386387
{ text: '设置指定消息附件的存储方式', link: 'message_attachment_storage.html' },
387388
{ text: '消息表情回复', link: 'reaction.html' },
388-
{ text: '撤回消息和单向删除会话', link: 'message_recall.html' },
389+
{ text: '撤回消息', link: 'message_recall.html' },
390+
{ text: '单向删除会话', link: 'conversation_delete.html' },
389391
{ text: '单向删除漫游消息', link: 'message_delete.html' },
390392
{ text: '修改文本或自定义消息', link: 'message_modify_text_custom.html' },
391393
{ text: '获取离线消息数据', link: 'message_offline.html' },
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# 单向删除会话
2+
3+
你可以从服务器中单向删除会话,并且设置是否删除该会话在服务端的漫游消息。删除会话后,该用户将从服务器获取不到该会话。该会话的其他参与聊天用户仍然可以从服务器获取会话内容。
4+
5+
## 前提条件
6+
7+
要调用声网即时通讯 RESTful API,请确保满足以下要求:
8+
9+
- 已在[声网控制台](https://console.shengwang.cn/overview) [开通配置声网即时通讯 IM 服务](enable_im.html)
10+
- 已从服务端获取 app token,详见 [使用 Token 鉴权](token_authentication.html)
11+
- 了解声网即时通讯 IM API 的调用频率限制,详见 [接口频率限制](limitationapi.html)
12+
13+
## 认证方式
14+
15+
声网即时通讯 IM RESTful API 要求 Bearer HTTP 认证。每次发送 HTTP 请求时,都必须在请求头部填入如下 `Authorization` 字段:
16+
17+
`Authorization: Bearer YourAppToken`
18+
19+
为提高项目的安全性,声网使用 Token(动态密钥)对即将登录即时通讯系统的用户进行鉴权。即时通讯 RESTful API 推荐使用 app token 的 鉴权方式,详见 [使用 Token 鉴权](token_authentication.html)
20+
21+
## HTTP 请求
22+
23+
```http
24+
DELETE https://{host}/app-id/{app_id}/users/{username}/user_channel
25+
```
26+
27+
#### 路径参数
28+
29+
| 参数 | 类型 | 是否必需 | 描述 |
30+
| :--------- | :----- | :------- | :------------------------- |
31+
| `host` | String || 即时通讯 IM 分配的用于访问 RESTful API 的域名。 |
32+
| `app_id` | String || 声网为每个项目自动分配的 App ID,作为项目唯一标识。 |
33+
| `username` | String || 要删除会话的用户的唯一标识符,即用户 ID。 |
34+
35+
#### 请求 header
36+
37+
| 参数 | 类型 | 是否必需 | 描述 |
38+
| :-------------- | :----- | :------- | :------------------------------------------------------------------------------------------------------------------- |
39+
| `Authorization` | String || App 管理员的鉴权 token,格式为 `Bearer YourAppToken`,其中 `Bearer` 为固定字符,后面为英文空格和获取到的 app token。 |
40+
41+
#### 请求 body
42+
43+
| 参数 | 类型 | 是否必需 | 描述 |
44+
| :------------ | :----- | :------- | :------------------------- |
45+
| `channel` | String || 要删除的会话 ID。该参数的值取决于会话类型 `type` 的值:<br/> - `type``chat`,即单聊时,会话 ID 为对端用户 ID;<br/> - `type``groupchat`,即群聊时,会话 ID 为群组 ID。 |
46+
| `type` | String || 会话类型。<br/> - `chat`:单聊会话;<br/> -`groupchat`:群聊会话。 |
47+
| `delete_roam` | Bool || 是否删除该会话在服务端的漫游消息。<br/> - `true`:是。若删除了该会话的服务端消息,则用户无法从服务器拉取该会话的漫游消息。<br/> - `false`:否。用户仍可以从服务器拉取该会话的漫游消息。 |
48+
49+
## HTTP 响应
50+
51+
#### 响应 body
52+
53+
如果返回的 HTTP 状态码为 `200`,表示请求成功,响应包体中包含以下字段:
54+
55+
| 参数 | 类型 | 描述 |
56+
| :---------------- | :----- | :---------------------------- |
57+
| `path` | String | 请求路径,属于请求 URL 的一部分,开发者无需关注。 |
58+
| `uri` | String | 请求 URL。 |
59+
| `timestamp` | Long | HTTP 响应的 Unix 时间戳,单位为毫秒。 |
60+
| `entities` | JSON | 响应实体。 |
61+
| `action` | String | 请求方法。 |
62+
| `data` | JSON | 删除结果详情。 |
63+
| `data.result` | String | 删除结果,`ok` 表示成功,失败则直接返回错误码和原因。 |
64+
| `duration` | Int | 从发送 HTTP 请求到响应的时长,单位为毫秒。 |
65+
如果返回的 HTTP 状态码非 `200`,表示请求失败。你可以参考 [响应状态码](error.html) 了解可能的原因。
66+
67+
## 示例
68+
69+
#### 请求示例
70+
71+
```shell
72+
# 将 <YourAppToken> 替换为你在服务端生成的 App Token
73+
74+
curl -L -X DELETE 'https://XXXX/app-id/XXXX/users/u1/user_channel' \
75+
-H 'Authorization: Bearer <YourAppToken>' \
76+
-H 'Content-Type: application/json' \
77+
-H 'Accept: application/json' \
78+
-d '{
79+
"channel": "u2",
80+
"type": "chat",
81+
"delete_roam": true
82+
}'
83+
```
84+
85+
#### 响应示例
86+
87+
```json
88+
{
89+
"path": "/users/user_channel",
90+
"uri": "https://XXXX/XXXX/XXXX/users/u1/user_channel",
91+
"timestamp": 1638440544078,
92+
"entities": [],
93+
"action": "delete",
94+
"data": {
95+
"result": "ok"
96+
},
97+
"duration": 3
98+
}
99+
```
100+
101+
## 错误码
102+
103+
如果返回的 HTTP 状态码非 `200`,表示请求失败,可能提示以下错误码:
104+
105+
| HTTP 状态码 | 错误类型 | 错误提示 | 可能原因 | 处理建议 |
106+
|:---------|:-------------------|:----------------------|:-----------------|:----------|
107+
| 400 | invalid_request_body | Request body is invalid. Please check body is correct. | 请求体格式不正确。 | 检查请求体内容是否合法(字段类型是否正确) 。 |
108+
| 400 | illegal_argument | field channel cannot be null or empty | 请求参数 `channel` 是空字符串 | 输入正确的请求参数 `channel`|
109+
| 400 | illegal_argument | field type cannot be null or empty | 请求参数 `type` 是空字符串。 | 输入正确的请求参数 `type`|
110+
| 400 | illegal_argument | field delete_roam cannot be null | 请求参数 `delete_roam` 是空。 | 输入正确的请求参数`delete_roam`|
111+
112+
关于其他错误,你可以参考 [响应状态码](error.html) 了解可能的原因。

docs/document/server-side/error.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
| 用户体系管理 | 注册/删除用户、获取用户详情、修改用户密码、封禁/解禁用户、全局用户禁言、获取用户在线状态、获取用户离线消息数据、获取指定账号的在线登录设备。 | 关于错误码,详见[用户体系管理](account_system.html)中各接口对应的错误码列表。 |
4343
| 用户属性 | 设置/删除/获取用户属性、获取 app 下用户属性总大小。 | 关于错误码,详见[用户属性模块](userprofile.html)中各接口对应的错误码列表。 |
4444
| 用户关系 | 添加/移除好友、设置好友备注、获取好友列表和导入好友列表。 | 关于错误码,详见[用户关系管理模块](user_relationship.html)中各接口对应的错误码列表。|
45-
| 消息 | 消息相关功能,包括发送消息、上传/下载文件、撤回消息、删除漫游消息、修改/导入消息。 | 详见以下 API 对应的错误码列表:<br/> - [发送单聊消息](message_single.html) <br/> - [发送群聊消息](message_group.html) <br/> - [发送聊天室消息](message_chatroom.html)<br/> - [上传和下载文件](message_download.html) <br/> - [撤回消息和单向删除会话](message_recall.html)<br/> - [单向删除漫游消息](message_delete.html)<br/> - [修改文本或自定义消息](message_modify_text_custom.html) <br/> - [导入消息](message_import.html) |
45+
| 消息 | 消息相关功能,包括发送消息、上传/下载文件、撤回消息、删除漫游消息、修改/导入消息。 | 详见以下 API 对应的错误码列表:<br/> - [发送单聊消息](message_single.html) <br/> - [发送群聊消息](message_group.html) <br/> - [发送聊天室消息](message_chatroom.html)<br/> - [发送全局广播消息](message_broadcast.html)<br/> - [上传和下载文件](message_download.html) <br/> - [撤回消息](message_recall.html)<br/> - [单向删除会话](conversation_delete.html)<br/> - [单向删除漫游消息](message_delete.html)<br/> - [修改文本或自定义消息](message_modify_text_custom.html) <br/> - [导入消息](message_import.html) |
4646
| 群组 | 群组管理、群成员管理、子区管理。 | 关于错误码,详见[群组管理](group_manage.html)[群组文件管理](group_file.html)[群成员管理](group_member_obtain.html)[子区管理](group_thread.html)中各接口对应的错误码列表。 |
4747
| 聊天室 | 聊天室管理、聊天室属性管理、聊天室成员管理。 | 关于错误码,详见[超级管理员管理](chatroom_superadmin.html)[聊天室管理](chatroom_manage.html)[聊天室属性管理](chatroom_attribute.html)[聊天室成员管理](chatroom_member_obtain.html)中各接口对应的错误码列表。 |
4848
| 在线状态订阅 | 设置用户在线状态、订阅/取消订阅/查询用户在线状态、查询单个群组的在线成员数量。 | 关于错误码,详见[在线状态订阅](presence.html)中各接口对应的错误码列表。 |

docs/document/server-side/limitationapi.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717
| * 发送群聊消息 | POST | /app-id/{app_id}/messages/chatgroups | 对于单个 app,该 REST API 存在以下三个限制:<br/> - 20 条/秒/App ID <br/> - 20 次/秒 <br/> - 3 个群/次 |
1818
| * 发送定向消息 | POST | /app-id/{app_id}/messages/chatgroups/users | 100 条/秒/App ID |
1919
| * 发送聊天室消息 | POST | /app-id/{app_id}/messages/chatrooms | 对于单个 app,该 REST API 存在以下三个限制:<br/> - 100 条/秒 <br/> - 20 次/秒 <br/> - 10 个聊天室/次 |
20+
| * 向 app 在线用户发送广播消息 | POST | /app-id/{app_id}/messages/users/broadcast | 每分钟限 1 次,每天限 50 次(可联系商务提升该上限)。 |
2021
| * 发送聊天室广播消息 | POST | /app-id/{app_id}/messages/chatrooms/broadcast | 每分钟最多可发 10 次,而且每天最多可发 100 次广播消息。 |
2122
| 上传文件 | POST | /app-id/{app_id}/chatfiles | 100 次/秒/App ID |
2223
| 下载文件 | GET | /app-id/{app_id}/chatfiles/{file_uuid} | 100 次/秒/App ID |
2324
| * 获取历史消息(聊天记录)文件 | GET | /app-id/{app_id}/chatmessages/${time} | 10 次/分钟/App ID |
2425
| * 设置指定消息附件的存储方式 | POST | /app-id/{app_id}/users/{username}/chatfiles/lifetime | 100 次/秒/App ID |
25-
| * 服务端消息撤回 | POST | /app-id/{app_id}/messages/recall | 100 次/秒/App ID |
26-
| 服务端单向删除会话 | DELETE | /app-id/{app_id}/users/{userName}/user_channel | 5 次/分钟/单用户 ID,100 次/秒/App ID |
26+
| * 撤回单条消息 | POST | /app-id/{app_id}/messages/recall | 100 次/秒/App ID |
27+
| * 批量撤回消息 | POST | /app-id/{app_id}/messages/batch_recall | 100 次/秒/App ID |
28+
| 单向删除会话 | DELETE | /app-id/{app_id}/users/{userName}/user_channel | 5 次/分钟/单用户 ID,100 次/秒/App ID |
2729
| 修改文本或自定义消息 | PUT | /app-id/{app_id}/messages/rewrite/{msg_id} | 100 次/秒/App ID |
2830
| 根据消息 ID 单向删除单聊漫游消息 | DELETE | /app-id/{app_id}/rest/message/roaming/chat/user/{userId}?userId={userId}&msgIdList={msgIdList} | 100 次/秒/App ID |
2931
| 根据消息 ID 单向删除群聊漫游消息 | DELETE | /app-id/{app_id}/rest/message/roaming/group/user/{userId}?groupId={groupId}&msgIdList={msgIdList} | 100 次/秒/App ID |

0 commit comments

Comments
 (0)