From 9a016c0499e9d2a2decb7b9dce751051d67d0f72 Mon Sep 17 00:00:00 2001 From: Gianmaria Del Monte Date: Fri, 9 Feb 2024 13:59:32 +0100 Subject: [PATCH] propfind trashbin with spaces --- .../http/services/owncloud/ocdav/trashbin.go | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/internal/http/services/owncloud/ocdav/trashbin.go b/internal/http/services/owncloud/ocdav/trashbin.go index bcc94cc7eb..aae15ed25d 100644 --- a/internal/http/services/owncloud/ocdav/trashbin.go +++ b/internal/http/services/owncloud/ocdav/trashbin.go @@ -20,6 +20,7 @@ package ocdav import ( "context" + "encoding/base32" "encoding/xml" "fmt" "net/http" @@ -43,6 +44,7 @@ import ( // TrashbinHandler handles trashbin requests. type TrashbinHandler struct { gatewaySvc string + spaces bool } func (h *TrashbinHandler) init(c *Config) error { @@ -50,6 +52,30 @@ func (h *TrashbinHandler) init(c *Config) error { return nil } +func (h *TrashbinHandler) handleTrashbinSpaces(s *svc, w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + log := appctx.GetLogger(ctx) + + space, _ := router.ShiftPath(r.URL.Path) + + spaceId, err := base32.StdEncoding.DecodeString(space) + if err != nil { + log.Error().Err(err).Msgf("error decoding space id: %s", space) + w.WriteHeader(http.StatusBadRequest) + return + } + + path := string(spaceId) + log.Debug().Str("path", path).Msg("decoded space base path") + + u := appctx.ContextMustGetUser(ctx) + + if r.Method == MethodPropfind { + h.listTrashbin(w, r, s, u, path, "", "") + return + } +} + // Handler handles requests. func (h *TrashbinHandler) Handler(s *svc) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -61,6 +87,11 @@ func (h *TrashbinHandler) Handler(s *svc) http.Handler { return } + if true { // s.spaces + h.handleTrashbinSpaces(s, w, r) + return + } + var username string username, r.URL.Path = router.ShiftPath(r.URL.Path)