Skip to main content

Callback Before Importing Friends

Function Description

The App business server can use this callback to receive requests from users importing friends. The business server can refuse user requests to import friends or modify and intervene in these requests.

Precautions

  • To enable the callback, it is necessary to configure the callback URL and activate the corresponding switch for this callback protocol. Configuration methods can be found in the Callback Explanation document.
  • The direction of the callback is an HTTP/HTTPS POST request initiated by OpenIM Server to the App backend.
  • After receiving the callback request, the App business server must verify whether the command parameter in the request URL is its SDKNAME parameter.
  • The APP business server must respond to this request within the timeout period.

Scenarios That May Trigger This Callback

  • App users import friends through the client.
  • App administrators import friends through the REST API.

Timing of the Callback

  • Before OpenIM Server prepares to import friends.

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, method is POST
https://callbackurlCallback URL
CallbackCommandFixed value: ImportFriendReqBeforeCommand
contenttypeFixed value: JSON
Header NameExample ValueMandatoryTypeDescription
operationID1646445464564RequiredstringoperationID for global link tracing

Request Packet Example

{
"callbackCommand": "ImportFriendReqBeforeCommand",
"ownerUserID": "user123",
"friendUserIDs": ["user456", "user789"]
}

Request Packet Field Explanation

FieldTypeDescription
callbackCommandstringCallback command, here for before importing friends
ownerUserIDstringUser ID of the person initiating the friend import request
friendUserIDsarrayList of user IDs to be imported as friends

Response Packet Example

Allow Importing

Allows the user to import friends.

{
"actionCode": 0,
"errCode": 0,
"errMsg": "Success",
"errDlt": "",
"nextCode": "0"
}

Refuse Importing

Refuses the user's friend import request and provides an error message.

{
"actionCode": 1,
"errCode": 5001,
"errMsg": "User not allowed to import friends",
"errDlt": "The user does not meet the criteria for importing friends",
"nextCode": "1",
"ownerUserID": "user123",
"friendUserIDs": ["user456", "user789"]
}

Response Packet Field Explanation

FieldTypeDescription
actionCodeintIndicates if the business system's callback was executed correctly. 0 means the operation was successful, 1 means the operation failed.
errCodeint32Custom error code, ranging between 5000-9999. Set when actionCode is not 0.
errMsgstringSimple error message corresponding to the custom error code.
errDltstringDetailed error information corresponding to the custom error code.
nextCodestringNext step instruction, 0 means to allow continuing, 1 means to refuse to continue.
ownerUserIDstringUser ID of the person initiating the friend import request
friendUserIDsarrayList of user IDs to be imported as friends