alter callback fg

This commit is contained in:
wangchuxiao 2022-03-03 17:53:37 +08:00
parent 3698f1dab8
commit 2ed3fd3cba
3 changed files with 52 additions and 22 deletions

View File

@ -80,9 +80,24 @@ func callbackAfterSendGroupMsg(msg *pbChat.SendMsgReq) error {
return nil return nil
} }
log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg) log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg)
req := cbApi.CallbackAfterSendGroupMsgReq{CommonCallbackReq: cbApi.CommonCallbackReq{CallbackCommand:constant.CallbackAfterSendGroupMsgCommand}} req := cbApi.CallbackAfterSendGroupMsgReq{
CommonCallbackReq: cbApi.CommonCallbackReq{
CallbackCommand:constant.CallbackAfterSendGroupMsgCommand,
ServerMsgID: msg.MsgData.ServerMsgID,
ClientMsgID: msg.MsgData.ClientMsgID,
OperationID: msg.OperationID,
},
GroupMsg: cbApi.GroupMsg{
Msg: cbApi.Msg{
SendID: msg.MsgData.
},
GroupID: msg.MsgData.GroupID,
}
}
resp := &cbApi.CallbackAfterSendGroupMsgResp{CommonCallbackResp: cbApi.CommonCallbackResp{}} resp := &cbApi.CallbackAfterSendGroupMsgResp{CommonCallbackResp: cbApi.CommonCallbackResp{}}
utils.CopyStructFields(req, msg.MsgData)
//utils.CopyStructFields(req, msg.MsgData)
req.Content = string(msg.MsgData.Content) req.Content = string(msg.MsgData.Content)
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp) defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp)
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut); err != nil { if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut); err != nil {
@ -97,10 +112,21 @@ func callBackWordFilter(msg *pbChat.SendMsgReq) (canSend bool, err error) {
return true, nil return true, nil
} }
log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg) log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg)
req := cbApi.CallbackWordFilterReq{CommonCallbackReq: cbApi.CommonCallbackReq{CallbackCommand:constant.CallbackWordFilterCommand}} //req := cbApi.CallbackWordFilterReq{
// CommonCallbackReq: cbApi.CommonCallbackReq{
// CallbackCommand: constant.CallbackWordFilterCommand,
// ServerMsgID: msg.MsgData.ServerMsgID,
// ClientMsgID: msg.MsgData.ClientMsgID,
// OperationID: msg.OperationID,
// },
// Content: string(msg.MsgData.Content),
//}
req := cbApi.CallbackWordFilterReq{
CommonCallbackReq: cbApi.CommonCallbackReq{},
}
utils.CopyStructFields(req.CommonCallbackReq, msg.MsgData)
resp := &cbApi.CallbackWordFilterResp{CommonCallbackResp: cbApi.CommonCallbackResp{}} resp := &cbApi.CallbackWordFilterResp{CommonCallbackResp: cbApi.CommonCallbackResp{}}
utils.CopyStructFields(&req, msg.MsgData) //utils.CopyStructFields(&req., msg.MsgData)
req.Content = string(msg.MsgData.Content)
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp) defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp)
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackWordFilter.CallbackTimeOut); err != nil { if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackWordFilter.CallbackTimeOut); err != nil {
if !config.Config.Callback.CallbackWordFilter.CallbackFailedContinue { if !config.Config.Callback.CallbackWordFilter.CallbackFailedContinue {

View File

@ -1,10 +1,16 @@
package call_back_struct package call_back_struct
type CommonCallbackReq struct { type CommonCallbackReq struct {
CallbackCommand string `json:"callbackCommand"` CallbackCommand string `json:"callbackCommand"`
ServerMsgID string `json:"serverID"` ServerMsgID string `json:"serverID"`
ClientID string `json:"clientID"` ClientMsgID string `json:"clientID"`
OperationID string `json:"operationID"` OperationID string `json:"operationID"`
SenderPlatformID int32 `json:"senderPlatformID"`
SenderNickname string `json:"senderNickname"`
SessionType int32 `json:"sessionType"`
MsgFrom int32 `json:"MsgFrom"`
ContentType int32 `json:"contentType"`
Status int32 `json:"status"`
} }
type CommonCallbackResp struct { type CommonCallbackResp struct {

View File

@ -1,54 +1,52 @@
package call_back_struct package call_back_struct
type msg struct { type Msg struct {
SendID string `json:"sendID"` SendID string `json:"sendID"`
ClientMsgID string `json:"clientMsgID"`
ServerMsgID string `json:"serverMsgId"`
CreateTime int64 `json:"createTime"` CreateTime int64 `json:"createTime"`
Content string `json:"content"` Content string `json:"content"`
} }
type singleMsg struct { type SingleMsg struct {
msg Msg
RecvID string `json:"recvID"` RecvID string `json:"recvID"`
} }
type CallbackBeforeSendSingleMsgReq struct { type CallbackBeforeSendSingleMsgReq struct {
CommonCallbackReq CommonCallbackReq
singleMsg SingleMsg
} }
type CallbackBeforeSendSingleMsgResp struct { type CallbackBeforeSendSingleMsgResp struct {
CommonCallbackResp CommonCallbackResp
singleMsg SingleMsg
} }
type CallbackAfterSendSingleMsgReq struct { type CallbackAfterSendSingleMsgReq struct {
CommonCallbackReq CommonCallbackReq
singleMsg SingleMsg
} }
type CallbackAfterSendSingleMsgResp struct { type CallbackAfterSendSingleMsgResp struct {
CommonCallbackResp CommonCallbackResp
} }
type groupMsg struct { type GroupMsg struct {
msg Msg
GroupID string `json:"groupID"` GroupID string `json:"groupID"`
} }
type CallbackBeforeSendGroupMsgReq struct { type CallbackBeforeSendGroupMsgReq struct {
CommonCallbackReq CommonCallbackReq
groupMsg GroupMsg
} }
type CallbackBeforeSendGroupMsgResp struct { type CallbackBeforeSendGroupMsgResp struct {
CommonCallbackResp CommonCallbackResp
groupMsg GroupMsg
} }
type CallbackAfterSendGroupMsgReq struct { type CallbackAfterSendGroupMsgReq struct {
groupMsg GroupMsg
CommonCallbackReq CommonCallbackReq
} }