mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
fix GetUserInGroupMembers nil panic (#1324)
This commit is contained in:
parent
3d3781f8d8
commit
1aef30dac4
@ -475,11 +475,13 @@ func (s *groupServer) GetGroupAllMember(ctx context.Context, req *pbgroup.GetGro
|
||||
return nil, err
|
||||
}
|
||||
resp.Members = utils.Slice(members, func(e *relationtb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
||||
if e.Nickname == "" {
|
||||
e.Nickname = publicUserInfoMap[e.UserID].Nickname
|
||||
}
|
||||
if e.FaceURL == "" {
|
||||
e.FaceURL = publicUserInfoMap[e.UserID].FaceURL
|
||||
if userInfo, ok := publicUserInfoMap[e.UserID]; ok {
|
||||
if e.Nickname == "" {
|
||||
e.Nickname = userInfo.Nickname
|
||||
}
|
||||
if e.FaceURL == "" {
|
||||
e.FaceURL = userInfo.FaceURL
|
||||
}
|
||||
}
|
||||
return convert.Db2PbGroupMember(e)
|
||||
})
|
||||
@ -626,11 +628,13 @@ func (s *groupServer) GetGroupMembersInfo(ctx context.Context, req *pbgroup.GetG
|
||||
return nil, err
|
||||
}
|
||||
resp.Members = utils.Slice(members, func(e *relationtb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
||||
if e.Nickname == "" {
|
||||
e.Nickname = publicUserInfoMap[e.UserID].Nickname
|
||||
}
|
||||
if e.FaceURL == "" {
|
||||
e.FaceURL = publicUserInfoMap[e.UserID].FaceURL
|
||||
if userInfo, ok := publicUserInfoMap[e.UserID]; ok {
|
||||
if e.Nickname == "" {
|
||||
e.Nickname = userInfo.Nickname
|
||||
}
|
||||
if e.FaceURL == "" {
|
||||
e.FaceURL = userInfo.FaceURL
|
||||
}
|
||||
}
|
||||
return convert.Db2PbGroupMember(e)
|
||||
})
|
||||
@ -1073,18 +1077,20 @@ func (s *groupServer) GetGroupMembersCMS(ctx context.Context, req *pbgroup.GetGr
|
||||
return nil, err
|
||||
}
|
||||
resp.Total = total
|
||||
nameMap, err := s.GetPublicUserInfoMap(ctx, utils.Filter(members, func(e *relationtb.GroupMemberModel) (string, bool) {
|
||||
publicUserInfoMap, err := s.GetPublicUserInfoMap(ctx, utils.Filter(members, func(e *relationtb.GroupMemberModel) (string, bool) {
|
||||
return e.UserID, e.Nickname == "" || e.FaceURL == ""
|
||||
}), true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp.Members = utils.Slice(members, func(e *relationtb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
||||
if e.Nickname == "" {
|
||||
e.Nickname = nameMap[e.UserID].Nickname
|
||||
}
|
||||
if e.FaceURL == "" {
|
||||
e.FaceURL = nameMap[e.UserID].FaceURL
|
||||
if userInfo, ok := publicUserInfoMap[e.UserID]; ok {
|
||||
if e.Nickname == "" {
|
||||
e.Nickname = userInfo.Nickname
|
||||
}
|
||||
if e.FaceURL == "" {
|
||||
e.FaceURL = userInfo.FaceURL
|
||||
}
|
||||
}
|
||||
return convert.Db2PbGroupMember(e)
|
||||
})
|
||||
@ -1471,17 +1477,19 @@ func (s *groupServer) GetUserInGroupMembers(ctx context.Context, req *pbgroup.Ge
|
||||
return nil, err
|
||||
}
|
||||
publicUserInfoMap, err := s.GetPublicUserInfoMap(ctx, utils.Filter(members, func(e *relationtb.GroupMemberModel) (string, bool) {
|
||||
return e.UserID, e.Nickname == ""
|
||||
return e.UserID, e.Nickname == "" || e.FaceURL == ""
|
||||
}), true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp.Members = utils.Slice(members, func(e *relationtb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
||||
if e.Nickname == "" {
|
||||
e.Nickname = publicUserInfoMap[e.UserID].Nickname
|
||||
}
|
||||
if e.FaceURL == "" {
|
||||
e.FaceURL = publicUserInfoMap[e.UserID].FaceURL
|
||||
if userInfo, ok := publicUserInfoMap[e.UserID]; ok {
|
||||
if e.Nickname == "" {
|
||||
e.Nickname = userInfo.Nickname
|
||||
}
|
||||
if e.FaceURL == "" {
|
||||
e.FaceURL = userInfo.FaceURL
|
||||
}
|
||||
}
|
||||
return convert.Db2PbGroupMember(e)
|
||||
})
|
||||
@ -1513,11 +1521,13 @@ func (s *groupServer) GetGroupMemberRoleLevel(ctx context.Context, req *pbgroup.
|
||||
return nil, err
|
||||
}
|
||||
resp.Members = utils.Slice(members, func(e *relationtb.GroupMemberModel) *sdkws.GroupMemberFullInfo {
|
||||
if e.Nickname == "" {
|
||||
e.Nickname = publicUserInfoMap[e.UserID].Nickname
|
||||
}
|
||||
if e.FaceURL == "" {
|
||||
e.FaceURL = publicUserInfoMap[e.UserID].FaceURL
|
||||
if userInfo, ok := publicUserInfoMap[e.UserID]; ok {
|
||||
if e.Nickname == "" {
|
||||
e.Nickname = userInfo.Nickname
|
||||
}
|
||||
if e.FaceURL == "" {
|
||||
e.FaceURL = userInfo.FaceURL
|
||||
}
|
||||
}
|
||||
return convert.Db2PbGroupMember(e)
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user