|
|
|
@ -12,16 +12,19 @@ import (
|
|
|
|
|
|
|
|
|
|
func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) (canSend bool, err error) {
|
|
|
|
|
log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg)
|
|
|
|
|
if !config.Config.Callback.CallbackbeforeSendSingleMsg.Enable || msg.MsgData.ContentType != constant.Text {
|
|
|
|
|
if !config.Config.Callback.CallbackbeforeSendSingleMsg.Enable {
|
|
|
|
|
return true, nil
|
|
|
|
|
}
|
|
|
|
|
req := cbApi.CallbackBeforeSendSingleMsgReq{CommonCallbackReq:cbApi.CommonCallbackReq{
|
|
|
|
|
}}
|
|
|
|
|
resp := &cbApi.CallbackBeforeSendSingleMsgResp{CommonCallbackResp:cbApi.CommonCallbackResp{
|
|
|
|
|
}}
|
|
|
|
|
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, resp)
|
|
|
|
|
utils.CopyStructFields(req, msg.MsgData)
|
|
|
|
|
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackbeforeSendSingleMsg.CallbackTimeOut); err != nil && !config.Config.Callback.CallbackbeforeSendSingleMsg.CallbackFailedContinue{
|
|
|
|
|
return false, err
|
|
|
|
|
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackbeforeSendSingleMsg.CallbackTimeOut); err != nil{
|
|
|
|
|
if !config.Config.Callback.CallbackbeforeSendSingleMsg.CallbackFailedContinue {
|
|
|
|
|
return false, err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if resp.ActionCode == constant.ActionForbidden {
|
|
|
|
|
return false, nil
|
|
|
|
@ -32,13 +35,14 @@ func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) (canSend bool, err erro
|
|
|
|
|
|
|
|
|
|
func callbackAfterSendSingleMsg(msg *pbChat.SendMsgReq) error {
|
|
|
|
|
log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg)
|
|
|
|
|
if !config.Config.Callback.CallbackAfterSendSingleMsg.Enable || msg.MsgData.ContentType != constant.Text {
|
|
|
|
|
if !config.Config.Callback.CallbackAfterSendSingleMsg.Enable {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
req := cbApi.CallbackAfterSendSingleMsgReq{CommonCallbackReq: cbApi.CommonCallbackReq{}}
|
|
|
|
|
resp := &cbApi.CallbackAfterSendSingleMsgResp{CommonCallbackResp: cbApi.CommonCallbackResp{}}
|
|
|
|
|
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, resp)
|
|
|
|
|
utils.CopyStructFields(req, msg.MsgData)
|
|
|
|
|
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackAfterSendSingleMsg.CallbackTimeOut); err != nil && config.Config.Callback.CallbackAfterSendSingleMsg.CallbackFailedContinue{
|
|
|
|
|
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackAfterSendSingleMsg.CallbackTimeOut); err != nil{
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
@ -47,14 +51,17 @@ func callbackAfterSendSingleMsg(msg *pbChat.SendMsgReq) error {
|
|
|
|
|
|
|
|
|
|
func callbackBeforeSendGroupMsg(msg *pbChat.SendMsgReq) (canSend bool, err error) {
|
|
|
|
|
log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg)
|
|
|
|
|
if !config.Config.Callback.CallbackBeforeSendGroupMsg.Enable || msg.MsgData.ContentType != constant.Text {
|
|
|
|
|
if !config.Config.Callback.CallbackBeforeSendGroupMsg.Enable {
|
|
|
|
|
return true, nil
|
|
|
|
|
}
|
|
|
|
|
req := cbApi.CallbackBeforeSendSingleMsgReq{CommonCallbackReq: cbApi.CommonCallbackReq{}}
|
|
|
|
|
resp := &cbApi.CallbackBeforeSendGroupMsgResp{CommonCallbackResp: cbApi.CommonCallbackResp{}}
|
|
|
|
|
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, resp)
|
|
|
|
|
utils.CopyStructFields(req, msg.MsgData)
|
|
|
|
|
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackBeforeSendGroupMsg.CallbackTimeOut); err != nil && !config.Config.Callback.CallbackBeforeSendGroupMsg.CallbackFailedContinue{
|
|
|
|
|
return false, nil
|
|
|
|
|
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackBeforeSendGroupMsg.CallbackTimeOut); err != nil {
|
|
|
|
|
if !config.Config.Callback.CallbackBeforeSendGroupMsg.CallbackFailedContinue {
|
|
|
|
|
return false, nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if resp.ActionCode == constant.ActionForbidden {
|
|
|
|
|
return false, nil
|
|
|
|
@ -64,9 +71,16 @@ func callbackBeforeSendGroupMsg(msg *pbChat.SendMsgReq) (canSend bool, err error
|
|
|
|
|
|
|
|
|
|
func callbackAfterSendGroupMsg(msg *pbChat.SendMsgReq) error {
|
|
|
|
|
log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg)
|
|
|
|
|
if !config.Config.Callback.CallbackAfterSendGroupMsg.Enable || msg.MsgData.ContentType != constant.Text {
|
|
|
|
|
if !config.Config.Callback.CallbackAfterSendGroupMsg.Enable {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
req := cbApi.CallbackAfterSendGroupMsgReq{CommonCallbackReq: cbApi.CommonCallbackReq{}}
|
|
|
|
|
resp := &cbApi.CallbackAfterSendGroupMsgResp{CommonCallbackResp: cbApi.CommonCallbackResp{}}
|
|
|
|
|
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, resp)
|
|
|
|
|
utils.CopyStructFields(req, msg.MsgData)
|
|
|
|
|
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -76,13 +90,17 @@ func callBackWordFilter(msg *pbChat.SendMsgReq) (canSend bool, err error) {
|
|
|
|
|
if !config.Config.Callback.CallbackWordFilter.Enable || msg.MsgData.ContentType != constant.Text {
|
|
|
|
|
return true, nil
|
|
|
|
|
}
|
|
|
|
|
req := cbApi.CallBackWordFilterReq{
|
|
|
|
|
CommonCallbackReq: cbApi.CommonCallbackReq{},
|
|
|
|
|
}
|
|
|
|
|
resp := cbApi.CallBackWordFilterResp{CommonCallbackResp: cbApi.CommonCallbackResp{}}
|
|
|
|
|
req := cbApi.CallbackWordFilterReq{CommonCallbackReq: cbApi.CommonCallbackReq{}}
|
|
|
|
|
resp := &cbApi.CallbackWordFilterResp{CommonCallbackResp: cbApi.CommonCallbackResp{}}
|
|
|
|
|
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, resp)
|
|
|
|
|
utils.CopyStructFields(&req, msg.MsgData)
|
|
|
|
|
if err := http.PostReturn(msg.OperationID, req, &resp, config.Config.Callback.CallbackWordFilter.CallbackTimeOut); err != nil {
|
|
|
|
|
return false, err
|
|
|
|
|
if err := http.PostReturn(msg.OperationID, req, resp, config.Config.Callback.CallbackWordFilter.CallbackTimeOut); err != nil {
|
|
|
|
|
if !config.Config.Callback.CallbackWordFilter.CallbackFailedContinue {
|
|
|
|
|
return false, err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if resp.ActionCode == constant.ActionForbidden {
|
|
|
|
|
return false, nil
|
|
|
|
|
}
|
|
|
|
|
msg.MsgData.Content = resp.Content
|
|
|
|
|
return true, nil
|
|
|
|
|