mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-23 18:00:32 +08:00
SetGroupMemberInfo
This commit is contained in:
parent
103cb3cb99
commit
597a3cf9b5
@ -1217,23 +1217,32 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
|
|||||||
return nil, errs.ErrArgs.Wrap("invalid role level")
|
return nil, errs.ErrArgs.Wrap("invalid role level")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
opMember, ok := memberMap[[...]string{member.GroupID, opUserID}]
|
||||||
|
if !ok {
|
||||||
|
return nil, errs.ErrArgs.Wrap(fmt.Sprintf("user %s not in group %s", opUserID, member.GroupID))
|
||||||
|
}
|
||||||
if member.UserID == opUserID {
|
if member.UserID == opUserID {
|
||||||
if member.RoleLevel != nil {
|
if member.RoleLevel != nil {
|
||||||
return nil, errs.ErrNoPermission.Wrap("can not change self role level")
|
return nil, errs.ErrNoPermission.Wrap("can not change self role level")
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
opMember, ok := memberMap[[...]string{member.GroupID, opUserID}]
|
if opMember.RoleLevel == constant.GroupOrdinaryUsers {
|
||||||
if !ok {
|
return nil, errs.ErrNoPermission.Wrap("ordinary users can not change other role level")
|
||||||
return nil, errs.ErrArgs.Wrap(fmt.Sprintf("user %s not in group %s", opUserID, member.GroupID))
|
|
||||||
}
|
}
|
||||||
dbMember, ok := memberMap[[...]string{member.GroupID, member.UserID}]
|
dbMember, ok := memberMap[[...]string{member.GroupID, member.UserID}]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errs.ErrRecordNotFound.Wrap(fmt.Sprintf("user %s not in group %s", member.UserID, member.GroupID))
|
return nil, errs.ErrRecordNotFound.Wrap(fmt.Sprintf("user %s not in group %s", member.UserID, member.GroupID))
|
||||||
}
|
}
|
||||||
if opMember.RoleLevel == constant.GroupOrdinaryUsers {
|
//if opMember.RoleLevel == constant.GroupOwner {
|
||||||
return nil, errs.ErrNoPermission.Wrap("ordinary users can not change other role level")
|
// continue
|
||||||
}
|
//}
|
||||||
|
//if dbMember.RoleLevel == constant.GroupOwner {
|
||||||
|
// return nil, errs.ErrNoPermission.Wrap("change group owner")
|
||||||
|
//}
|
||||||
|
//if opMember.RoleLevel == constant.GroupAdmin && dbMember.RoleLevel == constant.GroupAdmin {
|
||||||
|
// return nil, errs.ErrNoPermission.Wrap("admin can not change other admin role info")
|
||||||
|
//}
|
||||||
switch opMember.RoleLevel {
|
switch opMember.RoleLevel {
|
||||||
case constant.GroupOrdinaryUsers:
|
case constant.GroupOrdinaryUsers:
|
||||||
return nil, errs.ErrNoPermission.Wrap("ordinary users can not change other role level")
|
return nil, errs.ErrNoPermission.Wrap("ordinary users can not change other role level")
|
||||||
@ -1241,6 +1250,9 @@ func (s *groupServer) SetGroupMemberInfo(ctx context.Context, req *pbGroup.SetGr
|
|||||||
if dbMember.RoleLevel != constant.GroupOrdinaryUsers {
|
if dbMember.RoleLevel != constant.GroupOrdinaryUsers {
|
||||||
return nil, errs.ErrNoPermission.Wrap("admin can not change other role level")
|
return nil, errs.ErrNoPermission.Wrap("admin can not change other role level")
|
||||||
}
|
}
|
||||||
|
if member.RoleLevel != nil {
|
||||||
|
return nil, errs.ErrNoPermission.Wrap("admin can not change other role level")
|
||||||
|
}
|
||||||
case constant.GroupOwner:
|
case constant.GroupOwner:
|
||||||
//if member.RoleLevel != nil && member.RoleLevel.Value == constant.GroupOwner {
|
//if member.RoleLevel != nil && member.RoleLevel.Value == constant.GroupOwner {
|
||||||
// return nil, errs.ErrNoPermission.Wrap("owner only one")
|
// return nil, errs.ErrNoPermission.Wrap("owner only one")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user