Invoke a Callback Before Applying to Join a Group

Last updated: 2020-06-10 18:37:39

    Feature Description

    The app backend uses this callback to monitor users’ requests to join groups in real time, including blocking these requests.

    Precautions

    • To enable this callback, you must configure the callback URL and toggle on the corresponding protocol. For details on the configuration method, see Third-Party Callback Configuration.
    • Callback direction: the IM backend initiates an HTTP POST request to the app backend.
    • After receiving the callback request, the app backend must check whether the SDKAppID contained in the request URL is consistent with its own SDKAppID.
    • For other security-related issues, see Third-Party Callback Overview: Security Considerations.

    Callback Triggering Scenarios

    This callback is triggered when an app user submits a request to join a group through the client.

    Callback Triggering Time

    This callback is triggered before the IM backend adds the requesting user to the group. (If the request needs to be approved by the admin, the callback occurs before the admin is notified.)

    API Description

    Request URL example

    In the following example, the callback URL configured in the app is https://www.example.com.
    Example:

    https://www.example.com?SdkAppid=$SDKAppID&CallbackCommand=$CallbackCommand&contenttype=json&ClientIP=$ClientIP&OptPlatform=$OptPlatform

    Request parameters

    Parameter Description
    https The request protocol is HTTPS, and the request method is POST.
    www.example.com The callback URL.
    SdkAppid The SDKAppID assigned by the IM console when an app is created.
    CallbackCommand The value is fixed to Group.CallbackBeforeApplyJoinGroup.
    contenttype The value is fixed to JSON.
    ClientIP The client IP address, whose format is similar to 127.0.0.1.
    OptPlatform The client platform. For details on the possible values, see the OptPlatform parameter in Third-Party Callback Overview: Callback Protocols.

    Request packet example

    {
        "CallbackCommand": "Group.CallbackBeforeApplyJoinGroup", // Callback command
        "GroupId" : "@TGS#2J4SZEAEL",
        "Type": "Public", // Group type
        "Requestor_Account": "jared" // Requester
    }

    Request packet fields

    Field Type Description
    CallbackCommand String The callback command.
    GroupId String The ID of the group that generates group messages.
    Type String The type of the group that generates group messages, such as Public. For details, see Group Types.
    Requestor_Account String The UserID of the requester.

    Response packet examples

    Allowing the processing to proceed

    Allows the system to continue to process the user’s request to join a group.

    {
        "ActionStatus": "OK",
        "ErrorInfo": "",
        "ErrorCode": 0 // Indicates that the system can continue to process the request to join the group.
    }

    Rejecting the request

    Disallows the system to continue to process the user’s request to join a group and returns error code 10016 to the caller.

    {
        "ActionStatus": "OK",
        "ErrorInfo": "",
        "ErrorCode": 1 // Indicates that the request to join a group is rejected.
    }

    Response packet fields

    Field Type Attribute Description
    ActionStatus String Required The request processing result. OK: succeeded. FAIL: failed.
    ErrorCode Integer Required The error code. 0: the system can continue to process the request. 1: the request is rejected. If the request needs to be approved by the admin, the system must wait for the admin to approve the request even if error code 0 is returned.
    ErrorInfo String Required Error information.

    References

    Third-party callback overview

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback
    Help