pull/232/head
wangchuxiao 3 years ago
parent 16a56457ed
commit 8967343079

@ -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

@ -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 {

@ -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)

@ -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 {

@ -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 {

Loading…
Cancel
Save