mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-18 21:46:19 -04:00
fix goconst bugs
This commit is contained in:
@@ -33,6 +33,13 @@ import (
|
||||
merrors "go-micro.dev/v4/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
_spaceTypePersonal = "personal"
|
||||
_spaceTypeProject = "project"
|
||||
|
||||
_sortDescending = "desc"
|
||||
)
|
||||
|
||||
var (
|
||||
_invalidSpaceNameCharacters = []string{`/`, `\`, `.`, `:`, `?`, `*`, `"`, `>`, `<`, `|`}
|
||||
_maxSpaceNameLength = 255
|
||||
@@ -253,8 +260,8 @@ func (g Graph) CreateDrive(w http.ResponseWriter, r *http.Request) {
|
||||
driveType = *drive.DriveType
|
||||
}
|
||||
switch driveType {
|
||||
case "", "project":
|
||||
driveType = "project"
|
||||
case "", _spaceTypeProject:
|
||||
driveType = _spaceTypeProject
|
||||
default:
|
||||
logger.Debug().Str("type", driveType).Msg("could not create drive: drives of this type cannot be created via this api")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "drives of this type cannot be created via this api")
|
||||
@@ -275,7 +282,7 @@ func (g Graph) CreateDrive(w http.ResponseWriter, r *http.Request) {
|
||||
csr.Opaque = utils.AppendPlainToOpaque(csr.Opaque, "spaceAlias", *drive.DriveAlias)
|
||||
}
|
||||
|
||||
if driveType == "personal" {
|
||||
if driveType == _spaceTypePersonal {
|
||||
csr.Owner = us
|
||||
}
|
||||
|
||||
@@ -911,7 +918,7 @@ func sortSpaces(req *godata.GoDataRequest, spaces []*libregraph.Drive) ([]*libre
|
||||
return nil, errors.Errorf("we do not support <%s> as a order parameter", req.Query.OrderBy.OrderByItems[0].Field.Value)
|
||||
}
|
||||
|
||||
if req.Query.OrderBy.OrderByItems[0].Order == "desc" {
|
||||
if req.Query.OrderBy.OrderByItems[0].Order == _sortDescending {
|
||||
sorter = sort.Reverse(sorter)
|
||||
}
|
||||
sort.Sort(sorter)
|
||||
|
||||
@@ -56,7 +56,7 @@ var sortTests = []sortTest{
|
||||
Query: &godata.GoDataQuery{
|
||||
OrderBy: &godata.GoDataOrderByQuery{
|
||||
OrderByItems: []*godata.OrderByItem{
|
||||
{Field: &godata.Token{Value: "name"}, Order: "desc"},
|
||||
{Field: &godata.Token{Value: "name"}, Order: _sortDescending},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -94,7 +94,7 @@ var sortTests = []sortTest{
|
||||
Query: &godata.GoDataQuery{
|
||||
OrderBy: &godata.GoDataOrderByQuery{
|
||||
OrderByItems: []*godata.OrderByItem{
|
||||
{Field: &godata.Token{Value: "lastModifiedDateTime"}, Order: "desc"},
|
||||
{Field: &godata.Token{Value: "lastModifiedDateTime"}, Order: _sortDescending},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -427,7 +427,7 @@ func sortGroups(req *godata.GoDataRequest, groups []*libregraph.Group) ([]*libre
|
||||
return nil, fmt.Errorf("we do not support <%s> as a order parameter", req.Query.OrderBy.OrderByItems[0].Field.Value)
|
||||
}
|
||||
|
||||
if req.Query.OrderBy.OrderByItems[0].Order == "desc" {
|
||||
if req.Query.OrderBy.OrderByItems[0].Order == _sortDescending {
|
||||
sorter = sort.Reverse(sorter)
|
||||
}
|
||||
sort.Sort(sorter)
|
||||
|
||||
@@ -499,7 +499,7 @@ func sortUsers(req *godata.GoDataRequest, users []*libregraph.User) ([]*libregra
|
||||
return nil, fmt.Errorf("we do not support <%s> as a order parameter", req.Query.OrderBy.OrderByItems[0].Field.Value)
|
||||
}
|
||||
|
||||
if req.Query.OrderBy.OrderByItems[0].Order == "desc" {
|
||||
if req.Query.OrderBy.OrderByItems[0].Order == _sortDescending {
|
||||
sorter = sort.Reverse(sorter)
|
||||
}
|
||||
sort.Sort(sorter)
|
||||
|
||||
@@ -9,12 +9,16 @@ import (
|
||||
"github.com/owncloud/ocis/v2/services/ocs/pkg/service/v0/response"
|
||||
)
|
||||
|
||||
const (
|
||||
_backendCS3 = "cs3"
|
||||
)
|
||||
|
||||
// ListUserGroups lists a users groups
|
||||
func (o Ocs) ListUserGroups(w http.ResponseWriter, r *http.Request) {
|
||||
userid := chi.URLParam(r, "userid")
|
||||
userid, _ = url.PathUnescape(userid)
|
||||
switch o.config.AccountBackend {
|
||||
case "cs3":
|
||||
case _backendCS3:
|
||||
// TODO
|
||||
o.mustRender(w, r, response.DataRender(&data.Groups{}))
|
||||
return
|
||||
@@ -27,7 +31,7 @@ func (o Ocs) ListUserGroups(w http.ResponseWriter, r *http.Request) {
|
||||
// AddToGroup adds a user to a group
|
||||
func (o Ocs) AddToGroup(w http.ResponseWriter, r *http.Request) {
|
||||
switch o.config.AccountBackend {
|
||||
case "cs3":
|
||||
case _backendCS3:
|
||||
// TODO
|
||||
o.cs3WriteNotSupported(w, r)
|
||||
return
|
||||
@@ -39,7 +43,7 @@ func (o Ocs) AddToGroup(w http.ResponseWriter, r *http.Request) {
|
||||
// RemoveFromGroup removes a user from a group
|
||||
func (o Ocs) RemoveFromGroup(w http.ResponseWriter, r *http.Request) {
|
||||
switch o.config.AccountBackend {
|
||||
case "cs3":
|
||||
case _backendCS3:
|
||||
// TODO
|
||||
o.cs3WriteNotSupported(w, r)
|
||||
return
|
||||
@@ -51,21 +55,20 @@ func (o Ocs) RemoveFromGroup(w http.ResponseWriter, r *http.Request) {
|
||||
// ListGroups lists all groups
|
||||
func (o Ocs) ListGroups(w http.ResponseWriter, r *http.Request) {
|
||||
switch o.config.AccountBackend {
|
||||
case "cs3":
|
||||
case _backendCS3:
|
||||
// TODO
|
||||
o.mustRender(w, r, response.DataRender(&data.Groups{}))
|
||||
return
|
||||
default:
|
||||
o.logger.Fatal().Msgf("Invalid accounts backend type '%s'", o.config.AccountBackend)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// AddGroup adds a group
|
||||
// oC10 implementation: https://github.com/owncloud/core/blob/762780a23c9eadda4fb5fa8db99eba66a5100b6e/apps/provisioning_api/lib/Groups.php#L126-L154
|
||||
func (o Ocs) AddGroup(w http.ResponseWriter, r *http.Request) {
|
||||
switch o.config.AccountBackend {
|
||||
case "cs3":
|
||||
case _backendCS3:
|
||||
o.cs3WriteNotSupported(w, r)
|
||||
return
|
||||
default:
|
||||
@@ -76,7 +79,7 @@ func (o Ocs) AddGroup(w http.ResponseWriter, r *http.Request) {
|
||||
// DeleteGroup deletes a group
|
||||
func (o Ocs) DeleteGroup(w http.ResponseWriter, r *http.Request) {
|
||||
switch o.config.AccountBackend {
|
||||
case "cs3":
|
||||
case _backendCS3:
|
||||
o.cs3WriteNotSupported(w, r)
|
||||
return
|
||||
default:
|
||||
@@ -87,12 +90,11 @@ func (o Ocs) DeleteGroup(w http.ResponseWriter, r *http.Request) {
|
||||
// GetGroupMembers lists all members of a group
|
||||
func (o Ocs) GetGroupMembers(w http.ResponseWriter, r *http.Request) {
|
||||
switch o.config.AccountBackend {
|
||||
case "cs3":
|
||||
case _backendCS3:
|
||||
// TODO
|
||||
o.mustRender(w, r, response.DataRender(&data.Users{}))
|
||||
return
|
||||
default:
|
||||
o.logger.Fatal().Msgf("Invalid accounts backend type '%s'", o.config.AccountBackend)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -11,6 +11,10 @@ import (
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/config/envdecode"
|
||||
)
|
||||
|
||||
const (
|
||||
_backendCS3 = "cs3"
|
||||
)
|
||||
|
||||
// ParseConfig loads configuration from known paths.
|
||||
func ParseConfig(cfg *config.Config) error {
|
||||
_, err := ociscfg.BindSourcesToStructs(cfg.Service.Name, cfg)
|
||||
@@ -38,19 +42,19 @@ func Validate(cfg *config.Config) error {
|
||||
return shared.MissingJWTTokenError(cfg.Service.Name)
|
||||
}
|
||||
|
||||
if cfg.PublicSharingDriver == "cs3" && cfg.PublicSharingDrivers.CS3.SystemUserAPIKey == "" {
|
||||
if cfg.PublicSharingDriver == _backendCS3 && cfg.PublicSharingDrivers.CS3.SystemUserAPIKey == "" {
|
||||
return shared.MissingSystemUserApiKeyError(cfg.Service.Name)
|
||||
}
|
||||
|
||||
if cfg.PublicSharingDriver == "cs3" && cfg.PublicSharingDrivers.CS3.SystemUserID == "" {
|
||||
if cfg.PublicSharingDriver == _backendCS3 && cfg.PublicSharingDrivers.CS3.SystemUserID == "" {
|
||||
return shared.MissingSystemUserID(cfg.Service.Name)
|
||||
}
|
||||
|
||||
if cfg.UserSharingDriver == "cs3" && cfg.UserSharingDrivers.CS3.SystemUserAPIKey == "" {
|
||||
if cfg.UserSharingDriver == _backendCS3 && cfg.UserSharingDrivers.CS3.SystemUserAPIKey == "" {
|
||||
return shared.MissingSystemUserApiKeyError(cfg.Service.Name)
|
||||
}
|
||||
|
||||
if cfg.UserSharingDriver == "cs3" && cfg.UserSharingDrivers.CS3.SystemUserID == "" {
|
||||
if cfg.UserSharingDriver == _backendCS3 && cfg.UserSharingDrivers.CS3.SystemUserID == "" {
|
||||
return shared.MissingSystemUserID(cfg.Service.Name)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user