* allow reference group changes
Этот коммит содержится в:
Ben Cooke
2025-03-31 15:49:55 -04:00
коммит произвёл GitHub
родитель 7e439a7f7e
Коммит ce9632cca3
10 изменённых файлов: 441 добавлений и 123 удалений

Просмотреть файл

@@ -301,7 +301,7 @@ func (s *SqlGroupStore) GetAllBySource(groupSource model.GroupSource) ([]*model.
return groups, nil
}
func (s *SqlGroupStore) GetByUser(userId string) ([]*model.Group, error) {
func (s *SqlGroupStore) GetByUser(userID string, opts model.GroupSearchOpts) ([]*model.Group, error) {
groups := []*model.Group{}
builder := s.getQueryBuilder().
@@ -310,11 +310,15 @@ func (s *SqlGroupStore) GetByUser(userId string) ([]*model.Group, error) {
Join("UserGroups ON UserGroups.Id = GroupMembers.GroupId").
Where(sq.Eq{
"GroupMembers.DeleteAt": 0,
"UserId": userId,
"UserId": userID,
})
if opts.FilterAllowReference {
builder = builder.Where("UserGroups.AllowReference = true")
}
if err := s.GetReplica().SelectBuilder(&groups, builder); err != nil {
return nil, errors.Wrapf(err, "failed to find Groups with userId=%s", userId)
return nil, errors.Wrapf(err, "failed to find Groups with userId=%s", userID)
}
return groups, nil