diff --git a/internal/msg_gateway/gate/callback.go b/internal/msg_gateway/gate/callback.go index 139d89afc..20d4837f1 100644 --- a/internal/msg_gateway/gate/callback.go +++ b/internal/msg_gateway/gate/callback.go @@ -9,7 +9,7 @@ import ( "time" ) -func callbackUserOnline(operationID, userID string, platformID int, token string, isAppBackgroundStatusChanged bool, connID string) cbApi.CommonCallbackResp { +func callbackUserOnline(operationID, userID string, platformID int, token string, isAppBackground bool, connID string) cbApi.CommonCallbackResp { callbackResp := cbApi.CommonCallbackResp{OperationID: operationID} if !config.Config.Callback.CallbackUserOnline.Enable { return callbackResp @@ -25,9 +25,9 @@ func callbackUserOnline(operationID, userID string, platformID int, token string }, UserID: userID, }, - Seq: int(time.Now().UnixNano() / 1e6), - IsAppBackgroundStatusChanged: isAppBackgroundStatusChanged, - ConnID: connID, + Seq: int(time.Now().UnixNano() / 1e6), + IsAppBackground: isAppBackground, + ConnID: connID, } callbackUserOnlineResp := &cbApi.CallbackUserOnlineResp{CommonCallbackResp: &callbackResp} if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackUserOnlineCommand, callbackUserOnlineReq, callbackUserOnlineResp, config.Config.Callback.CallbackUserOnline.CallbackTimeOut); err != nil { @@ -37,7 +37,7 @@ func callbackUserOnline(operationID, userID string, platformID int, token string return callbackResp } -func callbackUserOffline(operationID, userID string, platformID int, isAppBackgroundStatusChanged bool, connID string) cbApi.CommonCallbackResp { +func callbackUserOffline(operationID, userID string, platformID int, connID string) cbApi.CommonCallbackResp { callbackResp := cbApi.CommonCallbackResp{OperationID: operationID} if !config.Config.Callback.CallbackUserOffline.Enable { return callbackResp @@ -52,9 +52,8 @@ func callbackUserOffline(operationID, userID string, platformID int, isAppBackgr }, UserID: userID, }, - Seq: int(time.Now().UnixNano() / 1e6), - IsAppBackgroundStatusChanged: isAppBackgroundStatusChanged, - ConnID: connID, + Seq: int(time.Now().UnixNano() / 1e6), + ConnID: connID, } callbackUserOfflineResp := &cbApi.CallbackUserOfflineResp{CommonCallbackResp: &callbackResp} if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackUserOfflineCommand, callbackOfflineReq, callbackUserOfflineResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err != nil { diff --git a/internal/msg_gateway/gate/logic.go b/internal/msg_gateway/gate/logic.go index 4c8283b10..f249b9459 100644 --- a/internal/msg_gateway/gate/logic.go +++ b/internal/msg_gateway/gate/logic.go @@ -406,18 +406,10 @@ func (ws *WServer) setUserDeviceBackground(conn *UserConn, m *Req) { if isPass { req := pData.(*sdk_ws.SetAppBackgroundStatusReq) conn.IsBackground = req.IsBackground - if !conn.IsBackground { - callbackResp := callbackUserOnline(m.OperationID, conn.userID, int(conn.PlatformID), conn.token, true, conn.connID) - if callbackResp.ErrCode != 0 { - log.NewError(m.OperationID, utils.GetSelfFuncName(), "callbackUserOffline failed", callbackResp) - } - } else { - callbackResp := callbackUserOffline(m.OperationID, conn.userID, int(conn.PlatformID), true, conn.connID) - if callbackResp.ErrCode != 0 { - log.NewError(m.OperationID, utils.GetSelfFuncName(), "callbackUserOffline failed", callbackResp) - } + callbackResp := callbackUserOnline(m.OperationID, conn.userID, int(conn.PlatformID), conn.token, conn.IsBackground, conn.connID) + if callbackResp.ErrCode != 0 { + log.NewError(m.OperationID, utils.GetSelfFuncName(), "callbackUserOffline failed", callbackResp) } - log.NewInfo(m.OperationID, "SetUserDeviceBackground", "success", *conn, req.IsBackground) } ws.setUserDeviceBackgroundResp(conn, m, errCode, errMsg) diff --git a/internal/msg_gateway/gate/ws_server.go b/internal/msg_gateway/gate/ws_server.go index f7283514f..0d5869e11 100644 --- a/internal/msg_gateway/gate/ws_server.go +++ b/internal/msg_gateway/gate/ws_server.go @@ -388,7 +388,7 @@ func (ws *WServer) delUserConn(conn *UserConn) { if err != nil { log.Error(operationID, " close err", "", "uid", uid, "platform", platform) } - callbackResp := callbackUserOffline(operationID, conn.userID, platform, false, conn.connID) + callbackResp := callbackUserOffline(operationID, conn.userID, platform, conn.connID) if callbackResp.ErrCode != 0 { log.NewError(operationID, utils.GetSelfFuncName(), "callbackUserOffline failed", callbackResp) } diff --git a/pkg/call_back_struct/msg_gateway.go b/pkg/call_back_struct/msg_gateway.go index 235f63105..65d173829 100644 --- a/pkg/call_back_struct/msg_gateway.go +++ b/pkg/call_back_struct/msg_gateway.go @@ -2,10 +2,10 @@ package call_back_struct type CallbackUserOnlineReq struct { UserStatusCallbackReq - Token string `json:"token"` - Seq int `json:"seq"` - IsAppBackgroundStatusChanged bool `json:"isAppBackgroundStatusChanged"` - ConnID string `json:"connID"` + Token string `json:"token"` + Seq int `json:"seq"` + IsAppBackground bool `json:"isAppBackground"` + ConnID string `json:"connID"` } type CallbackUserOnlineResp struct { @@ -14,9 +14,8 @@ type CallbackUserOnlineResp struct { type CallbackUserOfflineReq struct { UserStatusCallbackReq - Seq int `json:"seq"` - IsAppBackgroundStatusChanged bool `json:"isAppBackgroundStatusChanged"` - ConnID string `json:"connID"` + Seq int `json:"seq"` + ConnID string `json:"connID"` } type CallbackUserOfflineResp struct {