From 3107f78b3cd593bc42431d358ffcbf5a955c8a24 Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Thu, 19 Oct 2023 16:39:22 +0200 Subject: [PATCH] add hidden status to sharedata MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: André Duffeck Signed-off-by: Christian Richter --- .../owncloud/ocs/handlers/apps/sharing/shares/pending.go | 9 +++++---- .../owncloud/ocs/handlers/apps/sharing/shares/shares.go | 2 +- pkg/conversions/main.go | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending.go index 52ee7be90d2..ed55fe436c3 100644 --- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending.go +++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending.go @@ -124,8 +124,7 @@ func (h *Handler) AcceptReceivedShare(w http.ResponseWriter, r *http.Request) { } for id := range sharesToAccept { - fieldMask := &fieldmaskpb.FieldMask{Paths: []string{"rejectshare"}} - data := h.updateReceivedShare(w, r, id, mount, fieldMask) + data := h.updateReceivedShare(w, r, id, mount, &fieldmaskpb.FieldMask{}) // only render the data for the changed share if id == shareID && data != nil { response.WriteOCSSuccess(w, r, []*conversions.ShareData{data}) @@ -136,7 +135,8 @@ func (h *Handler) AcceptReceivedShare(w http.ResponseWriter, r *http.Request) { // RejectReceivedShare handles DELETE Requests on /apps/files_sharing/api/v1/shares/{shareid} func (h *Handler) RejectReceivedShare(w http.ResponseWriter, r *http.Request) { shareID := chi.URLParam(r, "shareid") - data := h.updateReceivedShare(w, r, shareID, "", &fieldmaskpb.FieldMask{}) + fieldMask := &fieldmaskpb.FieldMask{Paths: []string{"rejectshare"}} + data := h.updateReceivedShare(w, r, shareID, "", fieldMask) if data != nil { response.WriteOCSSuccess(w, r, []*conversions.ShareData{data}) } @@ -160,7 +160,7 @@ func (h *Handler) updateReceivedShare(w http.ResponseWriter, r *http.Request, sh case "mountpoint": continue case "hidden": - hideFlag, _ = strconv.ParseBool(chi.URLParam(r, "hidden")) + hideFlag, _ = strconv.ParseBool(r.URL.Query().Get("hidden")) } } ctx := r.Context() @@ -222,6 +222,7 @@ func (h *Handler) updateReceivedShare(w http.ResponseWriter, r *http.Request, sh } data.State = mapState(rs.GetState()) + data.Hidden = rs.Hidden h.addFileInfo(ctx, data, info) h.mapUserIds(r.Context(), client, data) diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go index ab1b9ea3864..03350ad622b 100644 --- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go +++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go @@ -580,9 +580,9 @@ func (h *Handler) GetShare(w http.ResponseWriter, r *http.Request) { }, }) if err == nil && uRes.GetShare() != nil { - receivedshare = uRes.Share resourceID = uRes.Share.Share.ResourceId share, err = conversions.CS3Share2ShareData(ctx, uRes.Share.Share) + share.Hidden = uRes.Share.Hidden if err != nil { response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error mapping share data", err) return diff --git a/pkg/conversions/main.go b/pkg/conversions/main.go index ad5990b756d..755faa64ad3 100644 --- a/pkg/conversions/main.go +++ b/pkg/conversions/main.go @@ -172,6 +172,7 @@ type ShareData struct { Quicklink bool `json:"quicklink,omitempty" xml:"quicklink,omitempty"` // PasswordProtected represents a public share is password protected // PasswordProtected bool `json:"password_protected,omitempty" xml:"password_protected,omitempty"` + Hidden bool `json:"hidden" xml:"hidden"` } // ShareeData holds share recipient search results