跳到主要内容

创建群组之前的回调

功能说明

App 业务服务端可以通过该回调获取用户创建群组的请求,同时业务服务端可以拒绝用户创建群组的请求,或对请求做修改和干预。

注意事项

  • 为启用回调,必须配置回调 URL,并开启本条回调协议对应的开关。配置方法详见 回调说明 文档。
  • 回调的方向是 OpenIM Server 向 App 后台发起 HTTP/HTTPS POST 请求。
  • APP 业务服务端需在超时时间内响应此请求。

可能触发该回调的场景

  • App 用户通过客户端创建群组
  • App 管理员通过 REST API 创建群组

回调发生时机

  • OpenIM Server 准备创建群组之前。

接口说明

请求 URL 示例

以下示例中 App 配置的回调 URL 为 http://www.example.com/callbackCommand?contenttype=json

http://www.example.com/callbackBeforeCreateGroupCommand?contenttype=json

请求参数说明

参数说明
http请求协议为 HTTP,请求方式为 POST
www.example.comconfigy.yaml 中的 callback.url 字段,域名或主机名
CallbackCommand此处为:callbackBeforeCreateGroupCommand
contenttype固定值为:JSON
header名示例值选填类型说明
operationID1646445464564必填stringoperationID用于全局链路追踪

请求包示例

{
"callbackCommand": "callbackBeforeCreateGroupCommand",
"groupID": "12345",
"groupName": "MyGroup",
"notification": "Welcome to MyGroup!",
"introduction": "This is a group for discussing example topics.",
"faceURL": "http://example.com/path/to/face/image.png",
"ownerUserID": "user123",
"createTime": 1673048592000,
"memberCount": 10,
"ex": "Extra data",
"status": 1,
"creatorUserID": "user123",
"groupType": 1,
"needVerification": 1,
"lookMemberInfo": 1,
"applyMemberFriend": 0,
"notificationUpdateTime": 1673048592000,
"notificationUserID": "user456",
"initMemberList": [
{
"userID": "user789",
"roleLevel": 60
},
{
"userID": "user101112",
"roleLevel": 20
}
]
}

请求包字段说明

对象类型描述
callbackCommandstring回调命令,这里是创建群组之前的回调
groupIDstring群组的唯一标识符
groupNamestring群组的名称
notificationstring群组的通知信息
introductionstring群组的简介
faceURLstring群组的图标的URL
ownerUserIDstring群组所有者的用户ID
createTimeint64群组创建的时间戳(毫秒)
memberCountuint32群组的成员数量
exstring额外的数据字段
statusint32群组的状态
creatorUserIDstring群组的创建者的用户ID
groupTypeint32群组的类型
needVerificationint32是否需要验证加入群组
lookMemberInfoint32是否可以查看群成员信息
applyMemberFriendint32是否可以申请加群成员为好友
notificationUpdateTimeint64群通知的更新时间戳(毫秒)
notificationUserIDstring更新群通知的用户ID
initMemberListarray群组初始成员的列表,包括userID和roleLevel两个子字段
initMemberList.userIDstring初始成员的用户ID
initMemberList.roleLevelint32初始成员的角色等级

应答包示例

允许创建

{
"actionCode": 0,
"errCode": 0,
"errMsg": "Success",
"errDlt": "",
"nextCode": 0,
"groupID": "G001",
"groupName": "MyGroup",
"notification": "Welcome to MyGroup!",
"introduction": "A group for discussions",
"faceURL": "http://example.com/groupface.png",
"ownerUserID": "user01",
"ex": "Some extra data",
"status": 1,
"creatorUserID": "user02",
"groupType": 1,
"needVerification": 0,
"lookMemberInfo": 1,
"applyMemberFriend": 1
}

应答包字段说明

字段说明
actionCode0表示业务系统的回调是否正确执行。0表示操作成功。
errCode5001表示自定义错误码,范围在5000-9999之间。在 actionCode 不等于0时设置;在 nextCode 等于1时设置。
errMsg"An error message"自定义错误码对应的简单错误信息。
errDlt"Detailed error information"自定义错误码对应的详细错误信息。
nextCode1下一步执行指令,1表示拒绝继续执行,actionCode 等于0时设置。
groupIDstring群组的唯一标识符。
groupNamestring群组的名字。
notificationstring群组的通知/公告消息。
introductionstring群组的简介。
faceURLstring群组的图标或者图片的URL。
ownerUserIDstring群组拥有者的用户ID。
exstring额外的数据或信息。
statusint32群组的状态。
creatorUserIDstring创建群组的用户ID。
groupTypeint32群组的类型。
needVerificationint32是否需要验证才能加入群组。
lookMemberInfoint32是否可以查看群组成员信息。
applyMemberFriendint32是否可以申请成为群组成员的好友。