Browse Source

chore: update

wxyyxc1992 5 years ago
parent
commit
02ceed6058
1 changed files with 174 additions and 6 deletions
  1. 174
    6
      packages/cts-api/src/WebSocketClient.ts

+ 174
- 6
packages/cts-api/src/WebSocketClient.ts View File

@@ -133,15 +133,183 @@ export class WebSocketClient {
133 133
     return this.request('/v1/send/message', data);
134 134
   }
135 135
 
136
-  async markServiced(data: object) {
136
+  async markServiced(data: { msg_id: string }) {
137 137
     return this.request('/v1/mark/message/serviced', data);
138 138
   }
139 139
 
140
-  /**
141
-   *
142
-   * @param {*} data contact_id chat_type start_time limit
143
-   */
144
-  async getHistoryMessage(data: object) {
140
+  /** @start Apis */
141
+
142
+  /** 获取聊天室历史消息 */
143
+  async getHistoryMessage(data: {
144
+    contact_id: string;
145
+    chat_type: string;
146
+    start_time: number;
147
+    limit: number;
148
+  }) {
145 149
     return this.request('/v1/history/message', data);
146 150
   }
151
+
152
+  /** 修改在线状态 */
153
+  async updateStatus(data: { status: 'on' | 'off' | 'busy' }) {
154
+    return this.request('/v1/session/status', data);
155
+  }
156
+
157
+  /** 获取当前登陆用户的设备信息 */
158
+  async getSessionLists() {
159
+    return this.request('/v1/session/lists', {});
160
+  }
161
+
162
+  /** 增量获取所有会话信息 */
163
+  async getAllConversations(data: {
164
+    last_pull: number; // 最后一次获取的时间 0的话是全量获取
165
+  }) {
166
+    return this.request('/v1/get/all/conversation', data);
167
+  }
168
+
169
+  /** 获取联系人列表 */
170
+  async getAllContact(data: {
171
+    last_pull: number; // 最后一次获取的时间 0的话是全量获取
172
+  }) {
173
+    return this.request('/v1/get/all/contact', data);
174
+  }
175
+
176
+  /** 添加联系人 */
177
+  async addContact(data: { to_add_username: string; reason: string }) {
178
+    return this.request('/v1/add/contact', data);
179
+  }
180
+
181
+  /** 删除联系人 */
182
+  async deleteContact(data: { fid: string }) {
183
+    return this.request('/v1/delete/contact', data);
184
+  }
185
+
186
+  /** 屏蔽联系人 */
187
+  async maskingContact(data: { fid: string }) {
188
+    return this.request('/v1/add/contact/masking', data);
189
+  }
190
+
191
+  /** 取消联系人 */
192
+  async removeMaskingContact(data: { fid: string }) {
193
+    return this.request('/v1/remove/contact/masking', data);
194
+  }
195
+
196
+  /** 置顶联系人 */
197
+  async stickingContact(data: { fid: string }) {
198
+    return this.request('/v1/add/contact/stick', data);
199
+  }
200
+
201
+  /** 解除置顶联系人 */
202
+  async removeStickContact(data: { fid: string }) {
203
+    return this.request('/v1/remove/contact/stick', data);
204
+  }
205
+
206
+  /** 消息免打扰 */
207
+  async setNoDisturbing(data: { fid: string }) {
208
+    return this.request('/v1/add/contact/no/disturbing', data);
209
+  }
210
+
211
+  /** 取消消息免打扰 */
212
+  async removeNoDisturbing(data: { fid: string }) {
213
+    return this.request('/v1/remove/contact/no/disturbing', data);
214
+  }
215
+
216
+  /** 同意添加好友 */
217
+  async agreeAddContact(data: { id: string; to: string }) {
218
+    return this.request('/v1/add/contact/agree', data);
219
+  }
220
+
221
+  /** 拒绝添加好友 */
222
+  async rejectAddContact(data: { id: string; to: string }) {
223
+    return this.request('/v1/add/contact/reject', data);
224
+  }
225
+
226
+  /** 标记好友申请已发送 */
227
+  async addContactServiced(data: { id: string; to: string }) {
228
+    return this.request('/v1/add/contact/serviced', data);
229
+  }
230
+
231
+  /** 创建聊天室 */
232
+  async createChatroom(data: {
233
+    subject: string;
234
+    description: string;
235
+    welcome_message: string;
236
+    max: number;
237
+  }) {
238
+    return this.request('/v1/create/chatroom', data);
239
+  }
240
+
241
+  /** 销毁聊天室 */
242
+  async destroyChatroom(data: { room_id: string }) {
243
+    return this.request('/v1/destroy/chatroom', data);
244
+  }
245
+
246
+  /** 离开聊天室 */
247
+  async leaveChatroom(data: { room_id: string }) {
248
+    return this.request('/v1/leave/chatroom', data);
249
+  }
250
+
251
+  /** 获取聊天室详情 */
252
+  async getChatroomProfile(data: { room_id: string }) {
253
+    return this.request('/v1/get/chatroom/profile', data);
254
+  }
255
+
256
+  /** 修改聊天室名称 */
257
+  async updateChatroomSubject(data: { room_id: string }) {
258
+    return this.request('/v1/update/chatroom/subject', data);
259
+  }
260
+
261
+  /** 修改聊天室描述信息 */
262
+  async updateChatroomDescription(data: { room_id: string }) {
263
+    return this.request('/v1/update/chatroom/description', data);
264
+  }
265
+
266
+  /** 添加管理员 */
267
+  async addChatroomAdmin(data: { room_id: string; admin_id: string }) {
268
+    return this.request('/v1/add/chatroom/admin', data);
269
+  }
270
+
271
+  /** 移除管理员 */
272
+  async removeChatroomAdmin(data: { room_id: string; admin_id: string }) {
273
+    return this.request('/v1/remove/chatroom/admin', data);
274
+  }
275
+
276
+  /** 批量添加管理员 */
277
+  async addChatroomAdmins(data: { room_id: string; admins_id: string[] }) {
278
+    return this.request('/v1/add/chatroom/admins', data);
279
+  }
280
+
281
+  /** 批量移除管理员 */
282
+  async removeChatroomAdmins(data: { room_id: string; admins_id: string[] }) {
283
+    return this.request('/v1/remove/chatroom/admins', data);
284
+  }
285
+
286
+  /** 加入聊天室 */
287
+  async joinChatroom(data: {}) {
288
+    return this.request('/v1/join/chatroom', data);
289
+  }
290
+
291
+  /** 删除聊天室成员 */
292
+  async removeChatroomMember(data: { room_id: string; member: string }) {
293
+    return this.request('/v1/remove/chatroom/member', data);
294
+  }
295
+
296
+  /** 获取置顶聊天室列表 */
297
+  async fetchStickChatroom(data: { cache_time: number }) {
298
+    return this.request('/v1/fetch/stick/chatroom', data);
299
+  }
300
+
301
+  /** 获取聊天室成员 */
302
+  async fetchChatroomMembers(data: { room_id: string; authority: number }) {
303
+    return this.request('/v1/fetch/chatroom/members', data);
304
+  }
305
+
306
+  /** 搜索聊天室历史消息 */
307
+  async searchHistoryMessage(data: {
308
+    contact_id: string;
309
+    chat_type: string;
310
+    keyword: string;
311
+    limit: number;
312
+  }) {
313
+    return this.request('/v1/search/history/message', data);
314
+  }
147 315
 }