enable users to list all spaces

This commit is contained in:
David Christofas
2021-10-27 17:17:16 +02:00
parent b53c58ae8e
commit 2986265be7
6 changed files with 54 additions and 3 deletions
+22
View File
@@ -43,7 +43,29 @@ func (g Graph) GetDrives(w http.ResponseWriter, r *http.Request) {
return
}
permissions := make(map[string]struct{}, 1)
s := sproto.NewPermissionService("com.owncloud.api.settings", grpc.DefaultClient)
_, err = s.GetPermissionByID(ctx, &sproto.GetPermissionByIDRequest{
PermissionId: settingsSvc.ListAllSpacesPermissionID,
})
// No error means the user has the permission
if err == nil {
permissions[settingsSvc.ListAllSpacesPermissionName] = struct{}{}
}
value, err := json.Marshal(permissions)
if err != nil {
errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, err.Error())
return
}
res, err := client.ListStorageSpaces(ctx, &storageprovider.ListStorageSpacesRequest{
Opaque: &types.Opaque{Map: map[string]*types.OpaqueEntry{
"permissions": {
Decoder: "json",
Value: value,
},
}},
// TODO add filters?
})
switch {
+1
View File
@@ -58,6 +58,7 @@ func NewService(opts ...Option) Service {
account.JWTSecret(options.Config.TokenManager.JWTSecret)),
)
r.Route("/drives", func(r chi.Router) {
r.Get("/", svc.GetDrives)
r.Post("/", svc.CreateDrive)
})
r.Route("/Drive({firstSegmentIdentifier})", func(r chi.Router) {