Skip to content

Commit

Permalink
propfind trashbin with spaces
Browse files Browse the repository at this point in the history
gmgigi96 committed Feb 9, 2024
1 parent 9380528 commit 9a016c0
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions internal/http/services/owncloud/ocdav/trashbin.go
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ package ocdav

import (
"context"
"encoding/base32"
"encoding/xml"
"fmt"
"net/http"
@@ -43,13 +44,38 @@ import (
// TrashbinHandler handles trashbin requests.
type TrashbinHandler struct {
gatewaySvc string
spaces bool
}

func (h *TrashbinHandler) init(c *Config) error {
h.gatewaySvc = c.GatewaySvc
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)

0 comments on commit 9a016c0

Please sign in to comment.