From 1c8542448815a12d7df205e9137700c43a8448f8 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Fri, 29 Jul 2022 17:09:21 +0800 Subject: [PATCH] mongodb superGroup --- internal/push/logic/callback.go | 6 +++++- internal/push/logic/push_to_client.go | 13 ++++++++++--- pkg/call_back_struct/push.go | 1 + 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/internal/push/logic/callback.go b/internal/push/logic/callback.go index 9cd5158ba..cc897322d 100644 --- a/internal/push/logic/callback.go +++ b/internal/push/logic/callback.go @@ -11,7 +11,7 @@ import ( 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} if !config.Config.Callback.CallbackOfflinePush.Enable { return callbackResp @@ -46,6 +46,10 @@ func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb. 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 } diff --git a/internal/push/logic/push_to_client.go b/internal/push/logic/push_to_client.go index 11f304433..1ab1ee989 100644 --- a/internal/push/logic/push_to_client.go +++ b/internal/push/logic/push_to_client.go @@ -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") if callbackResp.ErrCode != 0 { log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp) @@ -261,7 +261,9 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) { } } 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") if callbackResp.ErrCode != 0 { 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") return } + if len(offlinePushUserIDList) > 0 { + needOfflinePushUserIDList = offlinePushUserIDList + } else { + needOfflinePushUserIDList = onlineFailedUserIDList + } if offlinePusher == nil { return } @@ -278,7 +285,7 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) { log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "GetOfflinePushOpts failed", pushMsg, err.Error()) } 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 { log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error()) } else { diff --git a/pkg/call_back_struct/push.go b/pkg/call_back_struct/push.go index e0b46bd0c..e3803a0e2 100644 --- a/pkg/call_back_struct/push.go +++ b/pkg/call_back_struct/push.go @@ -15,6 +15,7 @@ type CallbackBeforePushReq struct { type CallbackBeforePushResp struct { *CommonCallbackResp + UserIDList []string `json:"userIDList"` } type CallbackBeforeSuperGroupOnlinePushReq struct {