mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-07 02:26:00 +08:00
groupCallback
This commit is contained in:
@@ -10,9 +10,9 @@ import (
|
||||
)
|
||||
|
||||
type ErrInfo struct {
|
||||
ErrCode int32
|
||||
ErrMsg string
|
||||
WrapErrMsg string
|
||||
ErrCode int32
|
||||
ErrMsg string
|
||||
DetailErrMsg string
|
||||
}
|
||||
|
||||
func (e ErrInfo) Error() string {
|
||||
@@ -24,13 +24,15 @@ func (e ErrInfo) Code() int32 {
|
||||
}
|
||||
|
||||
var (
|
||||
ErrNone = ErrInfo{0, "", ""}
|
||||
ErrRpcConn = ErrInfo{GRPCConnIsNil, "grpc conn is nil", ""}
|
||||
ErrArgs = ErrInfo{ArgsError, "ArgsError", ""}
|
||||
ErrDatabase = ErrInfo{DatabaseError, "DatabaseError", ""}
|
||||
ErrInternalServer = ErrInfo{ServerInternalError, "ServerInternalError", ""}
|
||||
ErrNetwork = ErrInfo{NetworkError, "NetworkError", ""}
|
||||
ErrNoPermission = ErrInfo{NoPermissionError, "NoPermissionError", ""}
|
||||
ErrNone = ErrInfo{0, "", ""}
|
||||
ErrRpcConn = ErrInfo{GRPCConnIsNil, "grpc conn is nil", ""}
|
||||
ErrArgs = ErrInfo{ArgsError, "ArgsError", ""}
|
||||
ErrDatabase = ErrInfo{DatabaseError, "DatabaseError", ""}
|
||||
ErrInternalServer = ErrInfo{ServerInternalError, "ServerInternalError", ""}
|
||||
ErrNetwork = ErrInfo{NetworkError, "NetworkError", ""}
|
||||
ErrNoPermission = ErrInfo{NoPermissionError, "NoPermissionError", ""}
|
||||
ErrCallback = ErrInfo{ErrMsg: "CallbackError"}
|
||||
ErrCallbackContinue = ErrInfo{ErrMsg: "CallbackContinueError"}
|
||||
|
||||
ErrUserIDNotFound = ErrInfo{UserIDNotFoundError, "UserIDNotFoundError", ""}
|
||||
ErrGroupIDNotFound = ErrInfo{GroupIDNotFoundError, "GroupIDNotFoundError", ""}
|
||||
@@ -62,7 +64,7 @@ var (
|
||||
|
||||
func toDetail(err error, info ErrInfo) ErrInfo {
|
||||
errInfo := info
|
||||
errInfo.WrapErrMsg = err.Error()
|
||||
errInfo.DetailErrMsg = err.Error()
|
||||
return errInfo
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ package http
|
||||
|
||||
import (
|
||||
cbApi "Open_IM/pkg/call_back_struct"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
@@ -57,22 +58,22 @@ func Post(url string, data interface{}, timeOutSecond int) (content []byte, err
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func CallBackPostReturn(url, callbackCommand string, input interface{}, output cbApi.CallbackResp, timeOut int, failedContinue *bool) (bool, error) {
|
||||
func CallBackPostReturn(url, callbackCommand string, input interface{}, output cbApi.CallbackResp, timeOut int, failedContinue *bool) error {
|
||||
v := urlLib.Values{}
|
||||
v.Set("callbackCommand", callbackCommand)
|
||||
url = url + "?" + v.Encode()
|
||||
b, err := Post(url, input, timeOut)
|
||||
if err != nil {
|
||||
if failedContinue != nil {
|
||||
return *failedContinue, err
|
||||
if failedContinue != nil && *failedContinue {
|
||||
return constant.ErrCallbackContinue
|
||||
}
|
||||
return true, err
|
||||
return constant.ErrNetwork
|
||||
}
|
||||
if err = json.Unmarshal(b, output); err != nil {
|
||||
if failedContinue != nil {
|
||||
return *failedContinue, err
|
||||
if failedContinue != nil && *failedContinue {
|
||||
return constant.ErrCallbackContinue
|
||||
}
|
||||
return true, err
|
||||
return constant.ErrData
|
||||
}
|
||||
return output.Parse()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user