This commit is contained in:
wangchuxiao 2022-05-27 10:26:44 +08:00
parent 098f8a52f7
commit f5befcc95f
5 changed files with 18 additions and 15 deletions

View File

@ -5,7 +5,9 @@ import (
"Open_IM/pkg/common/config" "Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant" "Open_IM/pkg/common/constant"
"Open_IM/pkg/common/http" "Open_IM/pkg/common/http"
"Open_IM/pkg/common/log"
commonPb "Open_IM/pkg/proto/sdk_ws" commonPb "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
http2 "net/http" http2 "net/http"
) )
@ -24,10 +26,11 @@ func callbackOfflinePush(operationID, userID string, info *commonPb.OfflinePushI
}, },
OfflinePushInfo: info, OfflinePushInfo: info,
} }
callbackOfflinePushResp := &cbApi.CallbackOfflinePushResp{CommonCallbackResp: callbackResp} callbackOfflinePushResp := &cbApi.CallbackOfflinePushResp{CommonCallbackResp: &callbackResp}
if err := http.PostReturn(config.Config.Callback.CallbackUrl, callbackOfflinePushReq, callbackOfflinePushResp, config.Config.Callback.CallbackOfflinePush.CallbackTimeOut); err != nil { if err := http.PostReturn(config.Config.Callback.CallbackUrl, callbackOfflinePushReq, callbackOfflinePushResp, config.Config.Callback.CallbackOfflinePush.CallbackTimeOut); err != nil {
callbackResp.ErrCode = http2.StatusInternalServerError callbackResp.ErrCode = http2.StatusInternalServerError
callbackResp.ErrMsg = err.Error() callbackResp.ErrMsg = err.Error()
} }
log.NewDebug(operationID, utils.GetSelfFuncName(), callbackOfflinePushResp)
return callbackResp return callbackResp
} }

View File

@ -111,6 +111,7 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp) log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp)
} }
if callbackResp.ActionCode != constant.ActionAllow { if callbackResp.ActionCode != constant.ActionAllow {
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline push was stop")
break break
} }

View File

@ -41,7 +41,7 @@ func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackRes
RecvID: msg.MsgData.RecvID, RecvID: msg.MsgData.RecvID,
} }
resp := &cbApi.CallbackBeforeSendSingleMsgResp{ resp := &cbApi.CallbackBeforeSendSingleMsgResp{
CommonCallbackResp: callbackResp, CommonCallbackResp: &callbackResp,
} }
//utils.CopyStructFields(req, msg.MsgData) //utils.CopyStructFields(req, msg.MsgData)
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp) defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp)
@ -71,7 +71,7 @@ func callbackAfterSendSingleMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp
CommonCallbackReq: commonCallbackReq, CommonCallbackReq: commonCallbackReq,
RecvID: msg.MsgData.RecvID, RecvID: msg.MsgData.RecvID,
} }
resp := &cbApi.CallbackAfterSendSingleMsgResp{CommonCallbackResp: callbackResp} resp := &cbApi.CallbackAfterSendSingleMsgResp{CommonCallbackResp: &callbackResp}
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.CallbackAfterSendSingleMsg.CallbackTimeOut); err != nil { if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackAfterSendSingleMsg.CallbackTimeOut); err != nil {
callbackResp.ErrCode = http2.StatusInternalServerError callbackResp.ErrCode = http2.StatusInternalServerError
@ -93,7 +93,7 @@ func callbackBeforeSendGroupMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp
CommonCallbackReq: commonCallbackReq, CommonCallbackReq: commonCallbackReq,
GroupID: msg.MsgData.GroupID, GroupID: msg.MsgData.GroupID,
} }
resp := &cbApi.CallbackBeforeSendGroupMsgResp{CommonCallbackResp: callbackResp} resp := &cbApi.CallbackBeforeSendGroupMsgResp{CommonCallbackResp: &callbackResp}
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.CallbackBeforeSendGroupMsg.CallbackTimeOut); err != nil { if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackBeforeSendGroupMsg.CallbackTimeOut); err != nil {
callbackResp.ErrCode = http2.StatusInternalServerError callbackResp.ErrCode = http2.StatusInternalServerError
@ -121,7 +121,7 @@ func callbackAfterSendGroupMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp
CommonCallbackReq: commonCallbackReq, CommonCallbackReq: commonCallbackReq,
GroupID: msg.MsgData.GroupID, GroupID: msg.MsgData.GroupID,
} }
resp := &cbApi.CallbackAfterSendGroupMsgResp{CommonCallbackResp: callbackResp} resp := &cbApi.CallbackAfterSendGroupMsgResp{CommonCallbackResp: &callbackResp}
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 {
callbackResp.ErrCode = http2.StatusInternalServerError callbackResp.ErrCode = http2.StatusInternalServerError
@ -142,7 +142,7 @@ func callbackWordFilter(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp {
req := cbApi.CallbackWordFilterReq{ req := cbApi.CallbackWordFilterReq{
CommonCallbackReq: commonCallbackReq, CommonCallbackReq: commonCallbackReq,
} }
resp := &cbApi.CallbackWordFilterResp{CommonCallbackResp: callbackResp} resp := &cbApi.CallbackWordFilterResp{CommonCallbackResp: &callbackResp}
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 {
callbackResp.ErrCode = http2.StatusInternalServerError callbackResp.ErrCode = http2.StatusInternalServerError

View File

@ -1,22 +1,21 @@
package call_back_struct package call_back_struct
type CallbackBeforeSendSingleMsgReq struct { type CallbackBeforeSendSingleMsgReq struct {
CommonCallbackReq CommonCallbackReq
RecvID string `json:"recvID"` RecvID string `json:"recvID"`
} }
type CallbackBeforeSendSingleMsgResp struct { type CallbackBeforeSendSingleMsgResp struct {
CommonCallbackResp *CommonCallbackResp
} }
type CallbackAfterSendSingleMsgReq struct { type CallbackAfterSendSingleMsgReq struct {
CommonCallbackReq CommonCallbackReq
RecvID string `json:"recvID"` RecvID string `json:"recvID"`
} }
type CallbackAfterSendSingleMsgResp struct { type CallbackAfterSendSingleMsgResp struct {
CommonCallbackResp *CommonCallbackResp
} }
type CallbackBeforeSendGroupMsgReq struct { type CallbackBeforeSendGroupMsgReq struct {
@ -25,7 +24,7 @@ type CallbackBeforeSendGroupMsgReq struct {
} }
type CallbackBeforeSendGroupMsgResp struct { type CallbackBeforeSendGroupMsgResp struct {
CommonCallbackResp *CommonCallbackResp
} }
type CallbackAfterSendGroupMsgReq struct { type CallbackAfterSendGroupMsgReq struct {
@ -34,7 +33,7 @@ type CallbackAfterSendGroupMsgReq struct {
} }
type CallbackAfterSendGroupMsgResp struct { type CallbackAfterSendGroupMsgResp struct {
CommonCallbackResp *CommonCallbackResp
} }
type CallbackWordFilterReq struct { type CallbackWordFilterReq struct {
@ -42,6 +41,6 @@ type CallbackWordFilterReq struct {
} }
type CallbackWordFilterResp struct { type CallbackWordFilterResp struct {
CommonCallbackResp *CommonCallbackResp
Content string `json:"content"` Content string `json:"content"`
} }

View File

@ -8,5 +8,5 @@ type CallbackOfflinePushReq struct {
} }
type CallbackOfflinePushResp struct { type CallbackOfflinePushResp struct {
CommonCallbackResp *CommonCallbackResp
} }