superGroupMaxSeq

This commit is contained in:
wangchuxiao
2022-07-22 16:55:29 +08:00
parent 337d01008b
commit a5ef78fd1e
4 changed files with 36 additions and 34 deletions
+17 -25
View File
@@ -13,34 +13,26 @@ func (rpc *rpcChat) GetMaxAndMinSeq(_ context.Context, in *open_im_sdk.GetMaxAnd
log.NewInfo(in.OperationID, "rpc getMaxAndMinSeq is arriving", in.String())
resp := new(open_im_sdk.GetMaxAndMinSeqResp)
m := make(map[string]*open_im_sdk.MaxAndMinSeq)
//seq, err := model.GetBiggestSeqFromReceive(in.UserID)
maxSeq, err1 := commonDB.DB.GetUserMaxSeq(in.UserID)
//minSeq, err2 := commonDB.DB.GetUserMinSeq(in.UserID)
if err1 == nil {
resp.MaxSeq = uint32(maxSeq)
for _, v := range in.GroupIDList {
x := new(open_im_sdk.MaxAndMinSeq)
maxSeq, _ := commonDB.DB.GetUserMaxSeq(v)
x.MaxSeq = uint32(maxSeq)
m[v] = x
}
resp.GroupMaxAndMinSeq = m
} else if err1 == go_redis.Nil {
resp.MaxSeq = 0
} else {
log.NewError(in.OperationID, "getMaxSeq from redis error", in.String(), err1.Error())
var maxSeq, minSeq uint64
var err error
maxSeq, err = commonDB.DB.GetUserMaxSeq(in.UserID)
minSeq, err = commonDB.DB.GetUserMinSeq(in.UserID)
if err != nil && err != go_redis.Nil {
log.NewError(in.OperationID, "getMaxSeq from redis error", in.String(), err.Error())
resp.ErrCode = 200
resp.ErrMsg = "redis get err"
return resp, nil
}
resp.MaxSeq = uint32(maxSeq)
resp.MinSeq = uint32(minSeq)
for _, groupID := range in.GroupIDList {
x := new(open_im_sdk.MaxAndMinSeq)
maxSeq, _ := commonDB.DB.GetGroupMaxSeq(groupID)
minSeq, _ := commonDB.DB.GetGroupUserMinSeq(groupID, in.UserID)
x.MaxSeq = uint32(maxSeq)
x.MinSeq = uint32(minSeq)
m[groupID] = x
}
//if err2 == nil {
// resp.MinSeq = uint32(minSeq)
//} else if err2 == redis.ErrNil {
// resp.MinSeq = 0
//} else {
// log.NewError(in.OperationID, "getMaxSeq from redis error", in.String(), err2.Error())
// resp.ErrCode = 201
// resp.ErrMsg = "redis get err"
//}
return resp, nil
}
func (rpc *rpcChat) PullMessageBySeqList(_ context.Context, in *open_im_sdk.PullMessageBySeqListReq) (*open_im_sdk.PullMessageBySeqListResp, error) {