Merge branch 'errcode' of github.com:OpenIMSDK/Open-IM-Server into errcode

test-errcode
wangchuxiao 1 year ago
commit 1b35ab4cf7

@ -77,3 +77,35 @@ func (s *groupServer) TakeGroupOwner(ctx context.Context, groupID string) (*rela
}
return owner, nil
}
func (s *groupServer) PageGetGroupMember(ctx context.Context, groupID string, pageNumber, showNumber int32) (uint32, []*relationTb.GroupMemberModel, error) {
total, members, err := s.GroupDatabase.PageGetGroupMember(ctx, groupID, pageNumber, showNumber)
if err != nil {
return 0, nil, err
}
emptyUserIDs := make(map[string]struct{})
for _, member := range members {
if member.Nickname == "" || member.FaceURL == "" {
emptyUserIDs[member.UserID] = struct{}{}
}
}
if len(emptyUserIDs) > 0 {
users, err := s.User.GetPublicUserInfoMap(ctx, utils.Keys(emptyUserIDs), true)
if err != nil {
return 0, nil, err
}
for i, member := range members {
user, ok := users[member.UserID]
if !ok {
continue
}
if member.Nickname == "" {
members[i].Nickname = user.Nickname
}
if member.FaceURL == "" {
members[i].FaceURL = user.FaceURL
}
}
}
return total, members, nil
}

@ -410,25 +410,13 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbGroup.GetGro
func (s *groupServer) GetGroupMemberList(ctx context.Context, req *pbGroup.GetGroupMemberListReq) (*pbGroup.GetGroupMemberListResp, error) {
resp := &pbGroup.GetGroupMemberListResp{}
total, members, err := s.GroupDatabase.PageGetGroupMember(ctx, req.GroupID, req.Pagination.PageNumber, req.Pagination.ShowNumber)
total, members, err := s.PageGetGroupMember(ctx, req.GroupID, req.Pagination.PageNumber, req.Pagination.ShowNumber)
log.ZDebug(ctx, "GetGroupMemberList", "total", total, "members", members, "length", len(members))
if err != nil {
return nil, err
}
resp.Total = total
nameMap, err := s.GetUsernameMap(ctx, utils.Filter(members, func(e *relationTb.GroupMemberModel) (string, bool) {
return e.UserID, e.Nickname == ""
}), true)
if err != nil {
return nil, err
}
log.ZDebug(ctx, "GetGroupMemberList", "nameMap", nameMap)
resp.Members = utils.Slice(members, func(e *relationTb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
if e.Nickname == "" {
e.Nickname = nameMap[e.UserID]
}
return convert.Db2PbGroupMember(e)
})
resp.Members = utils.Batch(convert.Db2PbGroupMember, members)
log.ZDebug(ctx, "GetGroupMemberList", "resp", resp, "length", len(resp.Members))
return resp, nil
}

Loading…
Cancel
Save