From 8967343079c5edaed726af7ffa642bba5e551de4 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Fri, 27 May 2022 19:33:47 +0800 Subject: [PATCH] superGroup --- internal/msg_gateway/gate/callback.go | 22 ++++++++++++++-------- internal/push/logic/callback.go | 14 ++++++++++---- internal/push/logic/push_to_client.go | 2 +- pkg/call_back_struct/msg_gateway.go | 2 ++ pkg/call_back_struct/push.go | 7 +++++++ 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/internal/msg_gateway/gate/callback.go b/internal/msg_gateway/gate/callback.go index 58d3a98b2..5f472c9f3 100644 --- a/internal/msg_gateway/gate/callback.go +++ b/internal/msg_gateway/gate/callback.go @@ -6,6 +6,7 @@ import ( "Open_IM/pkg/common/constant" "Open_IM/pkg/common/http" http2 "net/http" + "time" ) func callbackUserOnline(operationID, userID string, platformID int32, token string) cbApi.CommonCallbackResp { @@ -21,7 +22,9 @@ func callbackUserOnline(operationID, userID string, platformID int32, token stri UserID: userID, PlatformID: platformID, Platform: constant.PlatformIDToName(platformID), - }} + }, + Seq: time.Now().Nanosecond() / 1e6, + } callbackUserOnlineResp := &cbApi.CallbackUserOnlineResp{CommonCallbackResp: callbackResp} if err := http.PostReturn(config.Config.Callback.CallbackUrl, callbackUserOnlineReq, callbackUserOnlineResp, config.Config.Callback.CallbackUserOnline.CallbackTimeOut); err != nil { callbackResp.ErrCode = http2.StatusInternalServerError @@ -35,13 +38,16 @@ func callbackUserOffline(operationID, userID string, platform string) cbApi.Comm if !config.Config.Callback.CallbackUserOffline.Enable { return callbackResp } - callbackOfflineReq := cbApi.CallbackUserOfflineReq{UserStatusCallbackReq: cbApi.UserStatusCallbackReq{ - CallbackCommand: constant.CallbackUserOfflineCommand, - OperationID: operationID, - UserID: userID, - PlatformID: constant.PlatformNameToID(platform), - Platform: platform, - }} + callbackOfflineReq := cbApi.CallbackUserOfflineReq{ + UserStatusCallbackReq: cbApi.UserStatusCallbackReq{ + CallbackCommand: constant.CallbackUserOfflineCommand, + OperationID: operationID, + UserID: userID, + PlatformID: constant.PlatformNameToID(platform), + Platform: platform, + }, + Seq: time.Now().Nanosecond() / 1e6, + } callbackUserOfflineResp := &cbApi.CallbackUserOfflineResp{CommonCallbackResp: callbackResp} if err := http.PostReturn(config.Config.Callback.CallbackUrl, callbackOfflineReq, callbackUserOfflineResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err != nil { callbackResp.ErrCode = http2.StatusInternalServerError diff --git a/internal/push/logic/callback.go b/internal/push/logic/callback.go index 655751dc2..8e269e1dd 100644 --- a/internal/push/logic/callback.go +++ b/internal/push/logic/callback.go @@ -9,7 +9,7 @@ import ( http2 "net/http" ) -func callbackOfflinePush(operationID, userID string, info *commonPb.OfflinePushInfo, platformID int32) cbApi.CommonCallbackResp { +func callbackOfflinePush(operationID, userID string, msg *commonPb.MsgData) cbApi.CommonCallbackResp { callbackResp := cbApi.CommonCallbackResp{OperationID: operationID} if !config.Config.Callback.CallbackOfflinePush.Enable { return callbackResp @@ -19,10 +19,16 @@ func callbackOfflinePush(operationID, userID string, info *commonPb.OfflinePushI CallbackCommand: constant.CallbackOfflinePushCommand, OperationID: operationID, UserID: userID, - PlatformID: platformID, - Platform: constant.PlatformIDToName(platformID), + PlatformID: msg.SenderPlatformID, + Platform: constant.PlatformIDToName(msg.SenderPlatformID), }, - OfflinePushInfo: info, + OfflinePushInfo: msg.OfflinePushInfo, + SendID: msg.SendID, + GroupID: msg.GroupID, + ContentType: msg.ContentType, + SessionType: msg.SessionType, + AtUserIDList: msg.AtUserIDList, + Content: string(msg.Content), } callbackOfflinePushResp := &cbApi.CallbackOfflinePushResp{CommonCallbackResp: &callbackResp} if err := http.PostReturn(config.Config.Callback.CallbackUrl, callbackOfflinePushReq, callbackOfflinePushResp, config.Config.Callback.CallbackOfflinePush.CallbackTimeOut); err != nil { diff --git a/internal/push/logic/push_to_client.go b/internal/push/logic/push_to_client.go index 35618013a..ba657aff1 100644 --- a/internal/push/logic/push_to_client.go +++ b/internal/push/logic/push_to_client.go @@ -106,7 +106,7 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) { content = constant.ContentType2PushContent[constant.Common] } } - callbackResp := callbackOfflinePush(pushMsg.OperationID, UIDList[0], pushMsg.MsgData.OfflinePushInfo, v.RecvPlatFormID) + callbackResp := callbackOfflinePush(pushMsg.OperationID, UIDList[0], pushMsg.MsgData) log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline callback Resp") if callbackResp.ErrCode != 0 { log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp) diff --git a/pkg/call_back_struct/msg_gateway.go b/pkg/call_back_struct/msg_gateway.go index e6c3ec389..2fba45114 100644 --- a/pkg/call_back_struct/msg_gateway.go +++ b/pkg/call_back_struct/msg_gateway.go @@ -3,6 +3,7 @@ package call_back_struct type CallbackUserOnlineReq struct { UserStatusCallbackReq Token string `json:"token"` + Seq int `json:"seq"` } type CallbackUserOnlineResp struct { @@ -11,6 +12,7 @@ type CallbackUserOnlineResp struct { type CallbackUserOfflineReq struct { UserStatusCallbackReq + Seq int `json:"seq"` } type CallbackUserOfflineResp struct { diff --git a/pkg/call_back_struct/push.go b/pkg/call_back_struct/push.go index af7e38d79..271803679 100644 --- a/pkg/call_back_struct/push.go +++ b/pkg/call_back_struct/push.go @@ -5,6 +5,13 @@ import commonPb "Open_IM/pkg/proto/sdk_ws" type CallbackOfflinePushReq struct { UserStatusCallbackReq *commonPb.OfflinePushInfo + CommonCallbackReq + SendID string `json:"sendID"` + GroupID string `json:"groupID"` + ContentType int32 `json:"contentType"` + SessionType int32 `json:"sessionType"` + AtUserIDList []string `json:"atUserIDList"` + Content string `json` } type CallbackOfflinePushResp struct {