commit
59b625b7c0
@ -1,13 +1,78 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
cbApi "Open_IM/pkg/call_back_struct"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
pbGroup "Open_IM/pkg/proto/group"
|
||||
"Open_IM/pkg/utils"
|
||||
http2 "net/http"
|
||||
)
|
||||
|
||||
func callbackBeforeCreateGroup(req *pbGroup.CreateGroupReq) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func callbackAfterCreateGroup(req *pbGroup.CreateGroupReq) {
|
||||
|
||||
func callbackBeforeCreateGroup(req *pbGroup.CreateGroupReq) cbApi.CommonCallbackResp {
|
||||
callbackResp := cbApi.CommonCallbackResp{OperationID: req.OperationID}
|
||||
if !config.Config.Callback.CallbackBeforeCreateGroup.Enable {
|
||||
return callbackResp
|
||||
}
|
||||
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||
commonCallbackReq := &cbApi.CallbackBeforeCreateGroupReq{
|
||||
CallbackCommand: constant.CallbackBeforeCreateGroupCommand,
|
||||
}
|
||||
resp := &cbApi.CallbackBeforeCreateGroupResp{
|
||||
CommonCallbackResp: callbackResp,
|
||||
}
|
||||
//utils.CopyStructFields(req, msg.MsgData)
|
||||
defer log.NewDebug(req.OperationID, utils.GetSelfFuncName(), commonCallbackReq, *resp)
|
||||
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeCreateGroupCommand, commonCallbackReq, resp, config.Config.Callback.CallbackBeforeCreateGroup.CallbackTimeOut); err != nil {
|
||||
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||
callbackResp.ErrMsg = err.Error()
|
||||
if !config.Config.Callback.CallbackBeforeCreateGroup.CallbackFailedContinue {
|
||||
callbackResp.ActionCode = constant.ActionForbidden
|
||||
return callbackResp
|
||||
} else {
|
||||
callbackResp.ActionCode = constant.ActionAllow
|
||||
return callbackResp
|
||||
}
|
||||
}
|
||||
if resp.ErrCode == constant.CallbackHandleSuccess && resp.ActionCode == constant.ActionAllow {
|
||||
if resp.GroupID != nil {
|
||||
req.GroupInfo.GroupID = *resp.GroupID
|
||||
}
|
||||
if resp.GroupName != nil {
|
||||
req.GroupInfo.GroupName = *resp.GroupID
|
||||
}
|
||||
if resp.Notification != nil {
|
||||
req.GroupInfo.Notification = *resp.Notification
|
||||
}
|
||||
if resp.Introduction != nil {
|
||||
req.GroupInfo.Introduction = *resp.Introduction
|
||||
}
|
||||
if resp.FaceURL != nil {
|
||||
req.GroupInfo.FaceURL = *resp.FaceURL
|
||||
}
|
||||
if resp.OwnerUserID != nil {
|
||||
req.GroupInfo.OwnerUserID = *resp.OwnerUserID
|
||||
}
|
||||
if resp.Ex != nil {
|
||||
req.GroupInfo.Ex = *resp.Ex
|
||||
}
|
||||
if resp.Status != nil {
|
||||
req.GroupInfo.Status = *resp.Status
|
||||
}
|
||||
if resp.CreatorUserID != nil {
|
||||
req.GroupInfo.CreatorUserID = *resp.CreatorUserID
|
||||
}
|
||||
if resp.GroupType != nil {
|
||||
req.GroupInfo.GroupType = *resp.GroupType
|
||||
}
|
||||
if resp.NeedVerification != nil {
|
||||
req.GroupInfo.NeedVerification = *resp.GroupType
|
||||
}
|
||||
if resp.LookMemberInfo != nil {
|
||||
req.GroupInfo.LookMemberInfo = *resp.LookMemberInfo
|
||||
}
|
||||
}
|
||||
return callbackResp
|
||||
}
|
||||
|
@ -1,9 +1,27 @@
|
||||
package call_back_struct
|
||||
|
||||
import (
|
||||
commonPb "Open_IM/pkg/proto/sdk_ws"
|
||||
)
|
||||
|
||||
type CallbackBeforeCreateGroupReq struct {
|
||||
CommonCallbackReq
|
||||
CallbackCommand string `json:"callbackCommand"`
|
||||
commonPb.GroupInfo
|
||||
}
|
||||
|
||||
type CallbackAfterCreateGroupResp struct {
|
||||
type CallbackBeforeCreateGroupResp struct {
|
||||
CommonCallbackResp
|
||||
}
|
||||
GroupID *string `json:"groupID"`
|
||||
GroupName *string `json:"groupName"`
|
||||
Notification *string `json:"notification"`
|
||||
Introduction *string `json:"introduction"`
|
||||
FaceURL *string `json:"faceURL"`
|
||||
OwnerUserID *string `json:"ownerUserID"`
|
||||
Ex *string `json:"ex"`
|
||||
Status *int32 `json:"status"`
|
||||
CreatorUserID *string `json:"creatorUserID"`
|
||||
GroupType *int32 `json:"groupType"`
|
||||
NeedVerification *int32 `json:"needVerification"`
|
||||
LookMemberInfo *int32 `json:"lookMemberInfo"`
|
||||
ApplyMemberFriend *int32 `json:"applyMemberFriend"`
|
||||
}
|
||||
|
Loading…
Reference in new issue