Skip to content

Commit

Permalink
Filter shares based on type
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed May 5, 2021
1 parent 69bd21f commit 979fc66
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
}
Expand Down

0 comments on commit 979fc66

Please sign in to comment.