test-errcode
wangchuxiao 2 years ago
parent b2be663ba6
commit 71c836ae1a

@ -9,7 +9,7 @@ import (
"time"
)
func callbackUserOnline(operationID, userID string, platformID int, token string, isAppBackground bool) cbApi.CommonCallbackResp {
func callbackUserOnline(operationID, userID string, platformID int, token string, isAppBackgroundStatusChanged bool) cbApi.CommonCallbackResp {
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
if !config.Config.Callback.CallbackUserOnline.Enable {
return callbackResp
@ -25,8 +25,8 @@ func callbackUserOnline(operationID, userID string, platformID int, token string
},
UserID: userID,
},
Seq: int(time.Now().UnixNano() / 1e6),
IsAppBackground: isAppBackground,
Seq: int(time.Now().UnixNano() / 1e6),
IsAppBackgroundStatusChanged: isAppBackgroundStatusChanged,
}
callbackUserOnlineResp := &cbApi.CallbackUserOnlineResp{CommonCallbackResp: &callbackResp}
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackUserOnlineCommand, callbackUserOnlineReq, callbackUserOnlineResp, config.Config.Callback.CallbackUserOnline.CallbackTimeOut); err != nil {
@ -36,7 +36,7 @@ func callbackUserOnline(operationID, userID string, platformID int, token string
return callbackResp
}
func callbackUserOffline(operationID, userID string, platformID int) cbApi.CommonCallbackResp {
func callbackUserOffline(operationID, userID string, platformID int, isAppBackgroundStatusChanged bool) cbApi.CommonCallbackResp {
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
if !config.Config.Callback.CallbackUserOffline.Enable {
return callbackResp
@ -51,7 +51,8 @@ func callbackUserOffline(operationID, userID string, platformID int) cbApi.Commo
},
UserID: userID,
},
Seq: int(time.Now().UnixNano() / 1e6),
Seq: int(time.Now().UnixNano() / 1e6),
IsAppBackgroundStatusChanged: isAppBackgroundStatusChanged,
}
callbackUserOfflineResp := &cbApi.CallbackUserOfflineResp{CommonCallbackResp: &callbackResp}
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackUserOfflineCommand, callbackOfflineReq, callbackUserOfflineResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err != nil {

@ -406,10 +406,18 @@ func (ws *WServer) setUserDeviceBackground(conn *UserConn, m *Req) {
if isPass {
req := pData.(*sdk_ws.SetAppBackgroundStatusReq)
conn.IsBackground = req.IsBackground
callbackResp := callbackUserOnline(m.OperationID, conn.userID, int(conn.platformID), conn.token, conn.IsBackground)
if callbackResp.ErrCode != 0 {
log.NewError(m.OperationID, utils.GetSelfFuncName(), "callbackUserOffline failed", callbackResp)
if !conn.IsBackground {
callbackResp := callbackUserOnline(m.OperationID, conn.userID, int(conn.PlatformID), conn.token, true)
if callbackResp.ErrCode != 0 {
log.NewError(m.OperationID, utils.GetSelfFuncName(), "callbackUserOffline failed", callbackResp)
}
} else {
callbackResp := callbackUserOffline(m.OperationID, conn.userID, int(conn.PlatformID), true)
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)

@ -31,7 +31,7 @@ import (
type UserConn struct {
*websocket.Conn
w *sync.Mutex
platformID int32
PlatformID int32
PushedMaxSeq uint32
IsCompress bool
userID string
@ -386,7 +386,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)
callbackResp := callbackUserOffline(operationID, conn.userID, platform, false)
if callbackResp.ErrCode != 0 {
log.NewError(operationID, utils.GetSelfFuncName(), "callbackUserOffline failed", callbackResp)
}

@ -2,9 +2,9 @@ package call_back_struct
type CallbackUserOnlineReq struct {
UserStatusCallbackReq
Token string `json:"token"`
Seq int `json:"seq"`
IsAppBackground bool `json:"isAppBackground"`
Token string `json:"token"`
Seq int `json:"seq"`
IsAppBackgroundStatusChanged bool `json:"isAppBackgroundStatusChanged"`
}
type CallbackUserOnlineResp struct {
@ -13,7 +13,8 @@ type CallbackUserOnlineResp struct {
type CallbackUserOfflineReq struct {
UserStatusCallbackReq
Seq int `json:"seq"`
Seq int `json:"seq"`
IsAppBackgroundStatusChanged bool `json:"isAppBackgroundStatusChanged"`
}
type CallbackUserOfflineResp struct {

@ -73,11 +73,13 @@ func (d *DataBases) GetExtendMsgSet(ID string, index int32, opts *GetExtendMsgSe
return &set, err
}
func (d *DataBases) InsertExtendMsg(ID string, index int32, msg *ExtendMsg) error {
func (d *DataBases) InsertExtendMsg(ID string, index int32, msg *ExtendMsg) (msgIndex int32, err error) {
ctx, _ := context.WithTimeout(context.Background(), time.Duration(config.Config.Mongo.DBTimeout)*time.Second)
c := d.mongoClient.Database(config.Config.Mongo.DBDatabase).Collection(cExtendMsgSet)
_, err := c.UpdateOne(ctx, bson.M{"uid": GetExtendMsgSetID(ID, index)}, bson.M{"$set": bson.M{"create_time": utils.GetCurrentTimestampBySecond(), "$inc": bson.M{"extend_msg_num": 1}, "$push": bson.M{"extend_msgs": msg}}})
return err
result := c.FindOneAndUpdate(ctx, bson.M{"uid": GetExtendMsgSetID(ID, index)}, bson.M{"$set": bson.M{"create_time": utils.GetCurrentTimestampBySecond(), "$inc": bson.M{"extend_msg_num": 1}, "$push": bson.M{"extend_msgs": msg}}})
set := &ExtendMsgSet{}
err = result.Decode(set)
return set.ExtendMsgNum, err
}
func (d *DataBases) UpdateOneExtendMsgSet(ID string, index, MsgIndex int32, msg *ExtendMsg, msgSet *ExtendMsgSet) error {

@ -166,5 +166,4 @@ service msg {
rpc GetSendMsgStatus(GetSendMsgStatusReq) returns(GetSendMsgStatusResp);
rpc GetSuperGroupMsg(GetSuperGroupMsgReq) returns(GetSuperGroupMsgResp);
rpc GetWriteDiffMsg(GetWriteDiffMsgReq) returns(GetWriteDiffMsgResp);
}

Loading…
Cancel
Save