群管理

群主与管理员可修改群资料、转让群主、设置管理员与成员禁言。

平台调用风格

异步风格:Future<RcResult<T>>;错误码在 res.code,不使用异常表达业务失败。

接口一览​

操作语义传输返回
updateGroupName修改群名(群主/管理员)。REST(客户端)Group
updateGroupNotice设置群公告(群主/管理员,<=500 字,空串清除)。REST(客户端)Group
transferGroupOwner转让群主(新群主须为成员)。REST(客户端)Group
addGroupAdmin设置管理员(群主,幂等)。REST(客户端)Group
removeGroupAdmin取消管理员(群主)。REST(客户端)Group
muteGroupMember禁言/解禁(群主/管理员;不能禁言群主;管理员不能禁言管理员)。REST(客户端){groupId:string,userId:string,mutedUntil:uint64,group:Group}

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

跨端方法名​

操作AndroidWebElectronmacOSFlutterNative (C ABI)iOS
updateGroupNameupdateGroupNameupdateGroupNameupdateGroupNameupdateGroupNameupdateGroupName—func
updateGroupNoticeupdateGroupNoticeupdateGroupNoticeupdateGroupNoticeupdateGroupNoticeupdateGroupNotice—func
transferGroupOwnertransferGroupOwnertransferGroupOwnertransferGroupOwnertransferGroupOwnertransferGroupOwner—func
addGroupAdminaddGroupAdminaddGroupAdminaddGroupAdminaddGroupAdminaddGroupAdmin—func
removeGroupAdminremoveGroupAdminremoveGroupAdminremoveGroupAdminremoveGroupAdminremoveGroupAdmin—func
muteGroupMembermuteGroupMembermuteGroupMembermuteGroupMembermuteGroupMembermuteGroupMember—func

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

updateGroupName​

修改群名(群主/管理员)。

updateGroupName(String groupId, String name)
REST(客户端)since 1.0.0
参数
参数类型说明
groupIdstring必填;群组 ID
namestring必填;名称(群名 / 聊天室名 / 文件名)
返回

Group 群资料

示例
Dart
final res = await engine.updateGroupName('g_1001', '产品群');
if (res.code != 0) throw Exception(res.msg);
错误码
错误码名称分类HTTP可重试说明
1001INVALID_PARAMETER客户端 / 参数 / 权限400否参数错误
1003FORBIDDEN客户端 / 参数 / 权限403否无权限
1005GROUP_NOT_FOUND客户端 / 参数 / 权限404否群组不存在

updateGroupNotice​

设置群公告(群主/管理员,<=500 字,空串清除)。

updateGroupNotice(String groupId, String notice)
REST(客户端)since 1.0.0
参数
参数类型说明
groupIdstring必填;群组 ID
noticestring必填;群公告文本(<=500 字,空串清除)
返回

Group 群资料

示例
Dart
final res = await engine.updateGroupNotice('g_1001', '本周五 20:00 全员复盘');
if (res.code != 0) throw Exception(res.msg);
错误码
错误码名称分类HTTP可重试说明
1001INVALID_PARAMETER客户端 / 参数 / 权限400否参数错误
1003FORBIDDEN客户端 / 参数 / 权限403否无权限
1005GROUP_NOT_FOUND客户端 / 参数 / 权限404否群组不存在

transferGroupOwner​

转让群主(新群主须为成员)。

transferGroupOwner(String groupId, String newOwner)
REST(客户端)since 1.0.0
参数
参数类型说明
groupIdstring必填;群组 ID
newOwnerstring必填;新群主用户 ID(必须是群成员)
返回

Group 群资料

示例
Dart
final res = await engine.transferGroupOwner('g_1001', 'user2');
if (res.code != 0) throw Exception(res.msg);
错误码
错误码名称分类HTTP可重试说明
1001INVALID_PARAMETER客户端 / 参数 / 权限400否参数错误
1003FORBIDDEN客户端 / 参数 / 权限403否无权限
1004USER_NOT_FOUND客户端 / 参数 / 权限404否用户不存在
1005GROUP_NOT_FOUND客户端 / 参数 / 权限404否群组不存在

addGroupAdmin​

设置管理员(群主,幂等)。

addGroupAdmin(String groupId, String userId)
REST(客户端)幂等since 1.0.0
参数
参数类型说明
groupIdstring必填;群组 ID
userIdstring必填;用户 ID
返回

Group 群资料

示例
Dart
final res = await engine.addGroupAdmin('g_1001', 'user2');
if (res.code != 0) throw Exception(res.msg);
错误码
错误码名称分类HTTP可重试说明
1001INVALID_PARAMETER客户端 / 参数 / 权限400否参数错误
1003FORBIDDEN客户端 / 参数 / 权限403否无权限
1004USER_NOT_FOUND客户端 / 参数 / 权限404否用户不存在
1005GROUP_NOT_FOUND客户端 / 参数 / 权限404否群组不存在

removeGroupAdmin​

取消管理员(群主)。

removeGroupAdmin(String groupId, String userId)
REST(客户端)幂等since 1.0.0
参数
参数类型说明
groupIdstring必填;群组 ID
userIdstring必填;用户 ID
返回

Group 群资料

示例
Dart
final res = await engine.removeGroupAdmin('g_1001', 'user2');
if (res.code != 0) throw Exception(res.msg);
错误码
错误码名称分类HTTP可重试说明
1001INVALID_PARAMETER客户端 / 参数 / 权限400否参数错误
1003FORBIDDEN客户端 / 参数 / 权限403否无权限
1005GROUP_NOT_FOUND客户端 / 参数 / 权限404否群组不存在

muteGroupMember​

禁言/解禁(群主/管理员;不能禁言群主;管理员不能禁言管理员)。

muteGroupMember(String groupId, String userId, int mutedUntil)
REST(客户端)since 1.0.0
参数
参数类型说明
groupIdstring必填;群组 ID
userIdstring必填;用户 ID
mutedUntiluint64必填;禁言到期时间(epoch 毫秒;0 表示解除禁言)
返回

{groupId:string,userId:string,mutedUntil:uint64,group:Group} 成功返回的数据;失败时按错误码处理

示例
Dart
final res = await engine.muteGroupMember('g_1001', 'user2', 0);
if (res.code != 0) throw Exception(res.msg);
错误码
错误码名称分类HTTP可重试说明
1001INVALID_PARAMETER客户端 / 参数 / 权限400否参数错误
1003FORBIDDEN客户端 / 参数 / 权限403否无权限
1004USER_NOT_FOUND客户端 / 参数 / 权限404否用户不存在
1005GROUP_NOT_FOUND客户端 / 参数 / 权限404否群组不存在
1006NOT_GROUP_MEMBER客户端 / 参数 / 权限403否未加入群组

相关文档​