Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release

pull/258/head
Gordon 2 years ago
commit 3681bea8b7

@ -11,7 +11,7 @@ import (
http2 "net/http" http2 "net/http"
) )
func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb.MsgData) cbApi.CommonCallbackResp { func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb.MsgData, offlinePushUserIDList *[]string) cbApi.CommonCallbackResp {
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID} callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
if !config.Config.Callback.CallbackOfflinePush.Enable { if !config.Config.Callback.CallbackOfflinePush.Enable {
return callbackResp return callbackResp
@ -46,6 +46,10 @@ func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb.
return callbackResp return callbackResp
} }
} }
if resp.ErrCode == constant.CallbackHandleSuccess && resp.ActionCode == constant.ActionAllow && len(resp.UserIDList) != 0 {
*offlinePushUserIDList = resp.UserIDList
}
log.NewDebug(operationID, utils.GetSelfFuncName(), offlinePushUserIDList, resp.UserIDList)
return callbackResp return callbackResp
} }

@ -127,7 +127,7 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
} }
} }
callbackResp := callbackOfflinePush(pushMsg.OperationID, UIDList, pushMsg.MsgData) callbackResp := callbackOfflinePush(pushMsg.OperationID, UIDList, pushMsg.MsgData, &[]string{})
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline callback Resp") log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline callback Resp")
if callbackResp.ErrCode != 0 { if callbackResp.ErrCode != 0 {
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp) log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp)
@ -261,7 +261,9 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
} }
} }
if len(onlineFailedUserIDList) > 0 { if len(onlineFailedUserIDList) > 0 {
callbackResp := callbackOfflinePush(pushMsg.OperationID, onlineFailedUserIDList, pushMsg.MsgData) var offlinePushUserIDList []string
var needOfflinePushUserIDList []string
callbackResp := callbackOfflinePush(pushMsg.OperationID, onlineFailedUserIDList, pushMsg.MsgData, &offlinePushUserIDList)
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline callback Resp") log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline callback Resp")
if callbackResp.ErrCode != 0 { if callbackResp.ErrCode != 0 {
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp) log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp)
@ -270,6 +272,11 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offlinePush stop") log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offlinePush stop")
return return
} }
if len(offlinePushUserIDList) > 0 {
needOfflinePushUserIDList = offlinePushUserIDList
} else {
needOfflinePushUserIDList = onlineFailedUserIDList
}
if offlinePusher == nil { if offlinePusher == nil {
return return
} }
@ -278,7 +285,7 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "GetOfflinePushOpts failed", pushMsg, err.Error()) log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "GetOfflinePushOpts failed", pushMsg, err.Error())
} }
log.NewInfo(pushMsg.OperationID, utils.GetSelfFuncName(), onlineFailedUserIDList, content, jsonCustomContent, "opts:", opts) log.NewInfo(pushMsg.OperationID, utils.GetSelfFuncName(), onlineFailedUserIDList, content, jsonCustomContent, "opts:", opts)
pushResult, err := offlinePusher.Push(onlineFailedUserIDList, content, jsonCustomContent, pushMsg.OperationID, opts) pushResult, err := offlinePusher.Push(needOfflinePushUserIDList, content, jsonCustomContent, pushMsg.OperationID, opts)
if err != nil { if err != nil {
log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error()) log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error())
} else { } else {

@ -15,6 +15,7 @@ type CallbackBeforePushReq struct {
type CallbackBeforePushResp struct { type CallbackBeforePushResp struct {
*CommonCallbackResp *CommonCallbackResp
UserIDList []string `json:"userIDList"`
} }
type CallbackBeforeSuperGroupOnlinePushReq struct { type CallbackBeforeSuperGroupOnlinePushReq struct {

Loading…
Cancel
Save