|
| 1 | +--- |
| 2 | +title: 设置群组信息EX之前的回调 |
| 3 | +hide_title: true |
| 4 | +--- |
| 5 | + |
| 6 | +# 设置群组信息EX之前的回调 |
| 7 | + |
| 8 | +## 功能说明 |
| 9 | +App 业务服务端可以通过该回调在设置群组信息之前进行干预。这使得业务服务端可以在实际修改群组信息前,对请求进行审核或修改。 |
| 10 | + |
| 11 | +## 注意事项 |
| 12 | +- 为启用回调,必须配置回调 URL,并开启本条回调协议对应的开关。配置方法详见 [回调说明](../introduction) 文档。 |
| 13 | +- 回调的方向是 OpenIMServer 向 App 后台发起 HTTP/HTTPS POST 请求。 |
| 14 | +- APP 业务服务端需在超时时间内响应此请求。 |
| 15 | + |
| 16 | +## 可能触发该回调的场景 |
| 17 | +- App 用户通过客户端请求修改群组信息。 |
| 18 | +- App 管理员通过 REST API 修改群组信息。 |
| 19 | + |
| 20 | +## 回调发生时机 |
| 21 | +- OpenIMServer 收到设置群组信息的请求之后,处理该请求前。 |
| 22 | + |
| 23 | +## 接口说明 |
| 24 | + |
| 25 | +### 请求 URL 示例 |
| 26 | +以下示例中 App 配置的回调 URL 为 `http://www.example.com/callbackCommand?contenttype=json`。 |
| 27 | +```plaintext |
| 28 | +http://www.example.com/callbackBeforeSetGroupInfoEXCommand?contenttype=json |
| 29 | +``` |
| 30 | + |
| 31 | +### 请求参数说明 |
| 32 | + |
| 33 | +| 参数 | 说明 | |
| 34 | +|-----------------|-----------------------------------------------| |
| 35 | +| http | 请求协议为 HTTP,请求方式为 POST | |
| 36 | +| www.example.com | configy.yaml 中的 callback.url 字段,域名或主机名 | |
| 37 | +| CallbackCommand | 此处为:callbackBeforeSetGroupInfoEXCommand | |
| 38 | +| contenttype | 固定值为:JSON | |
| 39 | + |
| 40 | +### Header |
| 41 | +| header名 | 示例值 | 选填 | 类型 | 说明 | |
| 42 | +|:------------|:--------------|:----|--------|---------------------| |
| 43 | +| operationID | 1646445464564 | 必填 | string | operationID用于全局链路追踪 | |
| 44 | + |
| 45 | +### 请求包示例 |
| 46 | +```json |
| 47 | +{ |
| 48 | + "callbackCommand": "callbackBeforeSetGroupInfoEXCommand", |
| 49 | + "groupInfoForSet": { |
| 50 | + "groupID": "G002", |
| 51 | + "groupName": "NewGroupName", |
| 52 | + "notification": "Updated group notification", |
| 53 | + "introduction": "Updated group introduction", |
| 54 | + "faceURL": "http://example.com/new/path/to/face/image.png", |
| 55 | + "ex": { |
| 56 | + "value": "Updated extra data" |
| 57 | + }, |
| 58 | + "needVerification": { |
| 59 | + "value": 0 |
| 60 | + }, |
| 61 | + "lookMemberInfo": { |
| 62 | + "value": 1 |
| 63 | + }, |
| 64 | + "applyMemberFriend": { |
| 65 | + "value": 0 |
| 66 | + } |
| 67 | + } |
| 68 | +} |
| 69 | +``` |
| 70 | + |
| 71 | +### 请求包字段说明 |
| 72 | + |
| 73 | +| 字段 | 类型 | 描述 | |
| 74 | +|----------------------|------------|-------------------------------------------| |
| 75 | +| callbackCommand | string | 回调命令,这里为设置群组信息之前的回调 | |
| 76 | +| groupInfoForSet | object | 包含要设置的群组信息的对象 | |
| 77 | +| groupID | string | 群组的唯一标识符 | |
| 78 | +| groupName | string | 群组的名称 | |
| 79 | +| notification | StringValue | 群组的通知信息 | |
| 80 | +| introduction | StringValue | 群组的简介 | |
| 81 | +| faceURL | StringValue | 群组的图标的URL | |
| 82 | +| ex | StringValue| 额外的数据字段 | |
| 83 | +| needVerification | Int32Value | 是否需要验证加入群组 | |
| 84 | +| lookMemberInfo | Int32Value | 是否可以查看群成员信息 | |
| 85 | +| applyMemberFriend | Int32Value | 是否可以申请加群成员为好友 | |
| 86 | + |
| 87 | +## 应答包示例 |
| 88 | + |
| 89 | +### 允许修改 |
| 90 | +允许修改群组信息。 |
| 91 | + |
| 92 | +```json |
| 93 | +{ |
| 94 | + "actionCode": 0, |
| 95 | + "errCode": 0, |
| 96 | + "errMsg": "Success", |
| 97 | + "errDlt": "", |
| 98 | + "nextCode": "nextCodeValue", |
| 99 | + "groupInfoForSet": { |
| 100 | + "groupID": "G002", |
| 101 | + "groupName": "NewGroupName", |
| 102 | + "notification": "Updated group notification", |
| 103 | + "introduction": "Updated group introduction", |
| 104 | + "faceURL": "http://example.com/new/path/to/face/image.png", |
| 105 | + "ex": { |
| 106 | + "value": "Updated extra data" |
| 107 | + }, |
| 108 | + "needVerification": { |
| 109 | + "value": 0 |
| 110 | + }, |
| 111 | + "lookMemberInfo": { |
| 112 | + "value": 1 |
| 113 | + }, |
| 114 | + "applyMemberFriend": { |
| 115 | + "value": 0 |
| 116 | + } |
| 117 | + } |
| 118 | +} |
| 119 | +``` |
| 120 | + |
| 121 | +## 应答包字段说明 |
| 122 | + |
| 123 | +| 字段 | 类型 | 描述 | |
| 124 | +|---------------------|------------|-------------------------------------------| |
| 125 | +| actionCode | 0 | 表示业务系统的回调是否正确执行。`0`表示操作成功。 | |
| 126 | +| errCode | 5001 | 表示自定义错误码,范围在5000-9999之间。在 actionCode 不等于0时设置;在 nextCode 等于1时设置。| |
| 127 | +| errMsg | "An error message" | 自定义错误码对应的简单错误信息。| |
| 128 | +| errDlt | "Detailed error information" | 自定义错误码对应的详细错误信息。| |
| 129 | +| nextCode | 1 | 下一步执行指令,`1`表示拒绝继续执行,actionCode 等于`0`时设置。| |
| 130 | +| groupID | string | 群组的唯一标识符 | |
| 131 | +| groupName | string | 群组的名称 | |
| 132 | +| notification | StringValue | 群组的通知信息 | |
| 133 | +| introduction | StringValue | 群组的简介 | |
| 134 | +| faceURL | StringValue | 群组的图标的URL | |
| 135 | +| ex | StringValue| 额外的数据字段 | |
| 136 | +| needVerification | Int32Value | 是否需要验证加入群组 | |
| 137 | +| lookMemberInfo | Int32Value | 是否可以查看群成员信息 | |
| 138 | +| applyMemberFriend | Int32Value | 是否可以申请加群成员为好友 | |
| 139 | + |
0 commit comments