Merge pull request #4323 from owncloud/fix-user-drives-quota
fix listing of drives and quota
This commit is contained in:
@@ -4,4 +4,5 @@ We have added `$expand=drives` to the `/users/{id}/` endpoint
|
|||||||
using the user filter implemented in reva.
|
using the user filter implemented in reva.
|
||||||
|
|
||||||
https://github.com/owncloud/ocis/pull/4072
|
https://github.com/owncloud/ocis/pull/4072
|
||||||
https://github.com/cs3org/reva/pull/3046
|
https://github.com/cs3org/reva/pull/3046
|
||||||
|
https://github.com/owncloud/ocis/pull/4323
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import (
|
|||||||
revactx "github.com/cs3org/reva/v2/pkg/ctx"
|
revactx "github.com/cs3org/reva/v2/pkg/ctx"
|
||||||
"github.com/cs3org/reva/v2/pkg/events"
|
"github.com/cs3org/reva/v2/pkg/events"
|
||||||
"github.com/cs3org/reva/v2/pkg/rgrpc/status"
|
"github.com/cs3org/reva/v2/pkg/rgrpc/status"
|
||||||
|
"github.com/cs3org/reva/v2/pkg/utils"
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
"github.com/go-chi/render"
|
"github.com/go-chi/render"
|
||||||
libregraph "github.com/owncloud/libre-graph-api-go"
|
libregraph "github.com/owncloud/libre-graph-api-go"
|
||||||
@@ -180,8 +181,11 @@ func (g Graph) GetUser(w http.ResponseWriter, r *http.Request) {
|
|||||||
if slices.Contains(sel, "drive") || slices.Contains(sel, "drives") || slices.Contains(exp, "drive") || slices.Contains(exp, "drives") {
|
if slices.Contains(sel, "drive") || slices.Contains(sel, "drives") || slices.Contains(exp, "drive") || slices.Contains(exp, "drives") {
|
||||||
wdu, err := url.Parse(g.config.Spaces.WebDavBase + g.config.Spaces.WebDavPath)
|
wdu, err := url.Parse(g.config.Spaces.WebDavBase + g.config.Spaces.WebDavPath)
|
||||||
f := listStorageSpacesUserFilter(user.GetId())
|
f := listStorageSpacesUserFilter(user.GetId())
|
||||||
|
// use the unrestricted flag to get all possible spaces
|
||||||
|
// users with the canListAllSpaces permission should see all spaces
|
||||||
|
opaque := utils.AppendPlainToOpaque(nil, "unrestricted", "T")
|
||||||
lspr, err := g.gatewayClient.ListStorageSpaces(r.Context(), &storageprovider.ListStorageSpacesRequest{
|
lspr, err := g.gatewayClient.ListStorageSpaces(r.Context(), &storageprovider.ListStorageSpacesRequest{
|
||||||
Opaque: nil,
|
Opaque: opaque,
|
||||||
Filters: []*storageprovider.ListStorageSpacesRequest_Filter{f},
|
Filters: []*storageprovider.ListStorageSpacesRequest_Filter{f},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -202,6 +206,11 @@ func (g Graph) GetUser(w http.ResponseWriter, r *http.Request) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
g.logger.Err(err).Interface("query", r.URL.Query()).Msg("error converting space to drive")
|
g.logger.Err(err).Interface("query", r.URL.Query()).Msg("error converting space to drive")
|
||||||
}
|
}
|
||||||
|
quota, err := g.getDriveQuota(r.Context(), sp)
|
||||||
|
if err != nil {
|
||||||
|
g.logger.Err(err).Interface("query", r.URL.Query()).Msg("error calling get quota")
|
||||||
|
}
|
||||||
|
d.Quota = quota
|
||||||
if slices.Contains(sel, "drive") || slices.Contains(exp, "drive") {
|
if slices.Contains(sel, "drive") || slices.Contains(exp, "drive") {
|
||||||
if *d.DriveType == "personal" {
|
if *d.DriveType == "personal" {
|
||||||
drives = append(drives, *d)
|
drives = append(drives, *d)
|
||||||
|
|||||||
Reference in New Issue
Block a user