Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release

pull/261/head
Gordon 2 years ago
commit 319631b5c4

@ -239,7 +239,7 @@ func GetGroupAllMemberList(c *gin.Context) {
memberListResp := api.GetGroupAllMemberResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}, MemberList: RpcResp.MemberList}
memberListResp.Data = jsonData.JsonDataList(memberListResp.MemberList)
log.NewInfo(req.OperationID, "GetGroupAllMember api return ", memberListResp)
log.NewInfo(req.OperationID, "GetGroupAllMember api return ", len(memberListResp.MemberList))
c.JSON(http.StatusOK, memberListResp)
}

@ -510,7 +510,7 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGro
resp.MemberList = append(resp.MemberList, &node)
}
}
log.NewInfo(req.OperationID, "GetGroupAllMember rpc return ", resp.String())
log.NewInfo(req.OperationID, "GetGroupAllMember rpc return ", len(resp.MemberList))
return &resp, nil
}
@ -721,7 +721,7 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbGroup.GetG
resp.MemberList = []*open_im_sdk.GroupMemberFullInfo{}
for _, userID := range req.MemberList {
groupMember, err := rocksCache.GetGroupMemberInfoFromCache(req.GroupID, userID, "")
groupMember, err := rocksCache.GetGroupMemberInfoFromCache(req.GroupID, userID)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), req.GroupID, userID, err.Error())
continue

@ -186,7 +186,7 @@ func DelUserInfoFromCache(userID string) error {
return db.DB.Rc.TagAsDeleted(userInfoCache + userID)
}
func GetGroupMemberInfoFromCache(groupID, userID, fullKey string) (*db.GroupMember, error) {
func GetGroupMemberInfoFromCache(groupID, userID string) (*db.GroupMember, error) {
getGroupMemberInfo := func() (string, error) {
groupMemberInfo, err := imdb.GetGroupMemberInfoByGroupIDAndUserID(groupID, userID)
if err != nil {
@ -195,10 +195,7 @@ func GetGroupMemberInfoFromCache(groupID, userID, fullKey string) (*db.GroupMemb
bytes, err := json.Marshal(groupMemberInfo)
return string(bytes), utils.Wrap(err, "")
}
if fullKey == "" {
fullKey = groupMemberInfoCache + groupID + "-" + userID
}
groupMemberInfoStr, err := db.DB.Rc.Fetch(fullKey, time.Second*30*60, getGroupMemberInfo)
groupMemberInfoStr, err := db.DB.Rc.Fetch(groupMemberInfoCache+groupID+"-"+userID, time.Second*30*60, getGroupMemberInfo)
if err != nil {
return nil, utils.Wrap(err, "")
}
@ -212,38 +209,44 @@ func DelGroupMemberInfoFromCache(groupID, userID string) error {
}
func GetGroupMembersInfoFromCache(count, offset int32, groupID string) ([]*db.GroupMember, error) {
var cursor uint64
var err error
var keys, currentKeys []string
key := groupMemberInfoCache + groupID + "-"
groupMemberIDList, err := GetGroupMemberIDListFromCache(groupID)
if err != nil {
return nil, err
}
if count < 0 || offset < 0 {
return nil, nil
}
var groupMemberList []*db.GroupMember
var start, stop int32
start = offset
stop = offset + count
l := int32(len(groupMemberIDList))
if start > stop {
return nil, nil
}
if start >= l {
return nil, nil
}
if count != 0 {
keys, cursor, err = db.DB.RDB.Scan(context.Background(), uint64(offset), key, int64(count)).Result()
if err != nil {
return nil, err
if stop >= l {
stop = l
}
keys = append(keys, currentKeys...)
groupMemberIDList = groupMemberIDList[start:stop]
} else {
for {
var currentKeys []string
currentKeys, cursor, err = db.DB.RDB.Scan(context.Background(), cursor, key, int64(count)).Result()
if err != nil {
return nil, err
}
keys = append(keys, currentKeys...)
if cursor == 0 {
break
}
if l < 1000 {
stop = l
} else {
stop = 1000
}
groupMemberIDList = groupMemberIDList[start:stop]
}
var groupMemberList []*db.GroupMember
for _, key := range keys {
v, err := GetGroupMemberInfoFromCache("", "", key)
//log.NewDebug("", utils.GetSelfFuncName(), "ID list: ", groupMemberIDList)
for _, userID := range groupMemberIDList {
groupMembers, err := GetGroupMemberInfoFromCache(groupID, userID)
if err != nil {
log.NewError("", utils.GetSelfFuncName(), key, err.Error())
continue
log.NewError("", utils.GetSelfFuncName(), err.Error(), groupID, userID)
}
groupMemberList = append(groupMemberList, v)
groupMemberList = append(groupMemberList, groupMembers)
}
return groupMemberList, nil
}

Loading…
Cancel
Save