Skip to main content

Callback Before a User Joins a Group

Function Description

The App business server can view requests from users applying to join groups in real-time through this callback. This includes the ability of the App backend to intercept user requests to join groups.

Precautions

  • To enable the callback, a callback URL must be configured, and the switch corresponding to this callback protocol must be turned on. For configuration methods, refer to the Callback Description document.
  • The callback direction is an HTTP/HTTPS POST request initiated by OpenIM Server to the App backend.
  • The App business server, upon receiving the callback request, needs to verify if the command parameter in the request URL is their SDK parameter.
  • The APP business server needs to respond to this request within the timeout period.

Scenarios That May Trigger This Callback

  • App users initiate a request to join a group through the client.

Timing of the Callback

  • The callback occurs before OpenIM Server prepares to add a user to a group (if administrator approval is required, then before notifying the administrator).

Interface Description

Request URL Example

In the following example, the callback URL configured by the App is https://callbackurl.

https://callbackurl?command=$CallbackCommand&contenttype=json

Request Parameter Description

ParameterDescription
httpsRequest protocol is HTTPS, and the method is POST
https://callbackurlCallback URL
CallbackCommandFixed as: callbackBeforeApplyMemberJoinGroupCommand
contenttypeFixed value: JSON
Header NameExample ValueOptionalTypeDescription
operationID123456RequiredstringoperationID for global link tracing

Request Packet Example

{
"callbackCommand": "CallbackBeforeApplyMemberJoinGroupCommand",
"groupID": "12345",
"userID": "user789",
"ex": "Extra data",
"groupEx": "GroupExtra data"
}

Request Packet Field Description

ObjectTypeDescription
callbackCommandstringCallback command, here for pre-joining group member.
operationIDstringUnique operation ID.
userIDstringUser ID of the user joining the group.
groupIDstringUnique identifier for the group.
exstringAdditional data field.
groupExstringAdditional data field for the group.

Response Packet Example

Permitting to Join

{
"actionCode": 0,
"errCode": 0,
"errMsg": "",
"errDlt": "",
"nextCode": 0,
"roleLevel": "1",
"ex": "Some extra data"
}

Response Packet Field Description

FieldValueDescription
actionCode0Indicates if the callback was executed correctly by the business system. 0 means the operation was successful.
errCode5001Custom error code, ranging between 5000-9999. Set when actionCode is not 0 and nextCode is 1.
errMsg"An error message"Simple error message corresponding to the custom error code.
errDlt"Detailed error information"Detailed error information corresponding to the custom error code.
nextCode1Next step instruction, set when actionCode is 0, 1 means to refuse to proceed.
roleLevelstringPermission level of the user joining the group.
exstringAdditional data or information.