会话删除与类型免打扰

删除会话记录(只删会话行,不删历史消息)与按会话类型设置提醒级别;类型级设置优先于全局默认,单会话设置优先于类型级设置。

平台调用风格

异步风格:Promise<RcResult<T>>({ code, data?, msg? });业务错误通过 res.code !== 0 判断,不抛异常。

接口一览​

操作语义传输返回
deleteConversation删除会话记录(列表项/未读/草稿/置顶),历史消息保留;同时从标签移除;幂等。REST(客户端){removed:bool}
getConversationTypeNotification查询按会话类型默认免打扰级别(0 全部 / 1 仅 @ / 2 免打扰)。REST(客户端){conversationType:int, level:int}
setConversationTypeNotification设置按会话类型默认免打扰级别(0 全部 / 1 仅 @ / 2 免打扰)。REST(客户端){conversationType:int, level:int}

本页 3 个操作,其中 3 个在本平台绑定中声明了方法签名。

跨端方法名​

操作AndroidWebElectronmacOSFlutterNative (C ABI)iOS
deleteConversationdeleteConversationdeleteConversationdeleteConversationdeleteConversationdeleteConversation—func
getConversationTypeNotificationgetConversationTypeNotificationgetConversationTypeNotificationgetConversationTypeNotificationgetConversationTypeNotificationgetConversationTypeNotification—func
setConversationTypeNotificationsetConversationTypeNotificationsetConversationTypeNotificationsetConversationTypeNotificationsetConversationTypeNotificationsetConversationTypeNotification—func

方法名在 GA 平台之间保持一致(规则 A);Native C ABI 只覆盖部分操作,其余操作以 — 标注。

deleteConversation​

删除会话记录(列表项/未读/草稿/置顶),历史消息保留;同时从标签移除;幂等。

deleteConversation(conversationType, targetId)
REST(客户端)幂等since 1.2.0
参数
参数类型说明
conversationTypeConversationType必填;会话类型枚举(ConversationType)
targetIdstring必填;目标会话 ID:单聊为对方 userId,群聊为 groupId,聊天室为 chatroomId
返回

{removed:bool} 成功返回的数据;失败时按错误码处理

示例
JavaScript
const res = await client.deleteConversation(ConversationType.PRIVATE, 'user2');
if (res.code !== 0) throw new Error(res.msg);
const data = res.data;

该操作未声明专属错误码;失败时按 SDK 通用错误处理,见 状态码。

getConversationTypeNotification​

查询按会话类型默认免打扰级别(0 全部 / 1 仅 @ / 2 免打扰)。

getConversationTypeNotification(conversationType)
REST(客户端)幂等since 1.2.0
参数
参数类型说明
conversationTypeConversationType必填;会话类型枚举(ConversationType)
返回

{conversationType:int, level:int} 成功返回的数据;失败时按错误码处理

示例
JavaScript
const res = await client.getConversationTypeNotification(ConversationType.PRIVATE);
if (res.code !== 0) throw new Error(res.msg);
const data = res.data;
错误码
错误码名称分类HTTP可重试说明
1001INVALID_PARAMETER客户端 / 参数 / 权限400否参数错误

setConversationTypeNotification​

设置按会话类型默认免打扰级别(0 全部 / 1 仅 @ / 2 免打扰)。

setConversationTypeNotification(conversationType, level)
REST(客户端)幂等since 1.2.0
参数
参数类型说明
conversationTypeConversationType必填;会话类型枚举(ConversationType)
levelint必填;字段含义见类型定义
返回

{conversationType:int, level:int} 成功返回的数据;失败时按错误码处理

示例
JavaScript
const res = await client.setConversationTypeNotification(ConversationType.PRIVATE, NotificationLevel.ALL);
if (res.code !== 0) throw new Error(res.msg);
const data = res.data;
错误码
错误码名称分类HTTP可重试说明
1001INVALID_PARAMETER客户端 / 参数 / 权限400否参数错误

相关文档​