incorporate requested changes
Signed-off-by: Christian Richter <crichter@owncloud.com>
This commit is contained in:
@@ -11,10 +11,12 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/CiscoM31/godata"
|
"github.com/CiscoM31/godata"
|
||||||
|
cs3rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
|
||||||
storageprovider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
|
storageprovider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
|
||||||
ctxpkg "github.com/cs3org/reva/v2/pkg/ctx"
|
ctxpkg "github.com/cs3org/reva/v2/pkg/ctx"
|
||||||
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/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"
|
||||||
@@ -177,7 +179,6 @@ func (g Graph) GetUser(w http.ResponseWriter, r *http.Request) {
|
|||||||
exp := strings.Split(r.URL.Query().Get("$expand"), ",")
|
exp := strings.Split(r.URL.Query().Get("$expand"), ",")
|
||||||
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)
|
||||||
// TODO: filter this request for the user
|
|
||||||
f := listStorageSpacesUserFilter(user.GetId())
|
f := listStorageSpacesUserFilter(user.GetId())
|
||||||
lspr, err := g.gatewayClient.ListStorageSpaces(r.Context(), &storageprovider.ListStorageSpacesRequest{
|
lspr, err := g.gatewayClient.ListStorageSpaces(r.Context(), &storageprovider.ListStorageSpacesRequest{
|
||||||
Opaque: nil,
|
Opaque: nil,
|
||||||
@@ -185,6 +186,15 @@ 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 getting storages")
|
g.logger.Err(err).Interface("query", r.URL.Query()).Msg("error getting storages")
|
||||||
|
render.Status(r, http.StatusInternalServerError)
|
||||||
|
render.JSON(w, r, user)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if lspr.Status.Code != cs3rpc.Code_CODE_OK {
|
||||||
|
// in case of NOT_OK, we can just return the user object with empty drives
|
||||||
|
render.Status(r, status.HTTPStatusFromCode(http.StatusOK))
|
||||||
|
render.JSON(w, r, user)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
drives := []libregraph.Drive{}
|
drives := []libregraph.Drive{}
|
||||||
for _, sp := range lspr.GetStorageSpaces() {
|
for _, sp := range lspr.GetStorageSpaces() {
|
||||||
|
|||||||
Reference in New Issue
Block a user