From 979fc663da8226f7e20f3c6b56ae7489842064d8 Mon Sep 17 00:00:00 2001 From: Ishank Arora Date: Wed, 5 May 2021 14:25:32 +0200 Subject: [PATCH] Filter shares based on type --- .../handlers/apps/sharing/shares/shares.go | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) 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 1e25a9e0a54..81a3b2ace88 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 @@ -748,10 +748,13 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) { } func (h *Handler) listSharesWithOthers(w http.ResponseWriter, r *http.Request) { - shares := make([]*conversions.ShareData, 0) + userShares := make([]*conversions.ShareData, 0) + publicShares := make([]*conversions.ShareData, 0) + filters := []*collaboration.ListSharesRequest_Filter{} linkFilters := []*link.ListPublicSharesRequest_Filter{} var err error + var status *rpc.Status // shared with others p := r.URL.Query().Get("path") @@ -764,13 +767,17 @@ func (h *Handler) listSharesWithOthers(w http.ResponseWriter, r *http.Request) { } } - userShares, status, err := h.listUserShares(r, filters) - h.logProblems(status, err, "could not listUserShares") - - publicShares, status, err := h.listPublicShares(r, linkFilters) - h.logProblems(status, err, "could not listPublicShares") + shareTypes, err := strconv.Atoi(r.URL.Query().Get("share_types")) + if err != nil || shareTypes == int(conversions.ShareTypeUser) || shareTypes == int(conversions.ShareTypeGroup) { + userShares, status, err = h.listUserShares(r, filters) + h.logProblems(status, err, "could not listUserShares") + } + if err != nil || shareTypes == int(conversions.ShareTypePublicLink) { + publicShares, status, err = h.listPublicShares(r, linkFilters) + h.logProblems(status, err, "could not listPublicShares") + } - shares = append(shares, append(userShares, publicShares...)...) + shares := append(userShares, publicShares...) response.WriteOCSSuccess(w, r, shares) }