diff --git a/changelog/unreleased/ocs-filter-path-and-status.md b/changelog/unreleased/ocs-filter-path-and-status.md index c311a5d184..50342a37cb 100644 --- a/changelog/unreleased/ocs-filter-path-and-status.md +++ b/changelog/unreleased/ocs-filter-path-and-status.md @@ -2,4 +2,6 @@ Bugfix: filter share with me requests The OCS API now properly filters share with me requests by path and by share status (pending, accepted, rejected, all) +https://github.com/owncloud/ocis-reva/issues/260 +https://github.com/owncloud/ocis-reva/issues/311 https://github.com/cs3org/reva/pull/1301 \ No newline at end of file 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 c366f4a378..d9133cb05f 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 @@ -692,7 +692,7 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) { ctx := r.Context() - var info *provider.ResourceInfo + var pinfo *provider.ResourceInfo p := r.URL.Query().Get("path") // we need to lookup the resource id so we can filter the list of shares later if p != "" { @@ -732,7 +732,7 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) { return } - info = statRes.GetInfo() + pinfo = statRes.GetInfo() } lrsReq := collaboration.ListReceivedSharesRequest{} @@ -754,14 +754,25 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) { lrsRes.GetShares() shares := make([]*conversions.ShareData, 0) + + var info *provider.ResourceInfo // TODO(refs) filter out "invalid" shares for _, rs := range lrsRes.GetShares() { if stateFilter != ocsStateUnknown && rs.GetState() != stateFilter { continue } - - if info == nil { + if pinfo != nil { + // check if the shared resource matches the path resource + if rs.Share.ResourceId.StorageId != pinfo.GetId().StorageId || + rs.Share.ResourceId.OpaqueId != pinfo.GetId().OpaqueId { + // try next share + continue + } + // we can reuse the stat info + info = pinfo + } else { + // we need to do a stat call statRequest := provider.StatRequest{ Ref: &provider.Reference{ Spec: &provider.Reference_Id{ @@ -777,9 +788,6 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) { } info = statRes.GetInfo() - } else if rs.Share.ResourceId.StorageId != info.GetId().StorageId || - rs.Share.ResourceId.OpaqueId != info.GetId().OpaqueId { - continue } data, err := conversions.UserShare2ShareData(r.Context(), rs.Share) diff --git a/tests/acceptance/expected-failures-on-EOS-storage.txt b/tests/acceptance/expected-failures-on-EOS-storage.txt index 5b32af8fbf..529c698a76 100644 --- a/tests/acceptance/expected-failures-on-EOS-storage.txt +++ b/tests/acceptance/expected-failures-on-EOS-storage.txt @@ -346,10 +346,6 @@ apiSharePublicLink1/createPublicLinkShare.feature:779 # https://github.com/owncloud/core/issues/37605 Public cannot upload file with mtime set on a public link share with new version of WebDAV API apiSharePublicLink1/createPublicLinkShare.feature:793 # -# https://github.com/owncloud/ocis-reva/issues/311 Deleting a public link after renaming a file -apiSharePublicLink1/deletePublicLinkShare.feature:37 -apiSharePublicLink1/deletePublicLinkShare.feature:38 -# # https://github.com/owncloud/ocis-reva/issues/373 copying a folder within a public link folder to folder with same name as an already existing file overwrites the parent file apiSharePublicLink2/copyFromPublicLink.feature:60 # diff --git a/tests/acceptance/expected-failures-on-OCIS-storage.txt b/tests/acceptance/expected-failures-on-OCIS-storage.txt index 6595e9bd22..97afc0ab8d 100644 --- a/tests/acceptance/expected-failures-on-OCIS-storage.txt +++ b/tests/acceptance/expected-failures-on-OCIS-storage.txt @@ -206,7 +206,6 @@ apiShareManagementToShares/acceptShares.feature:160 apiShareManagementToShares/acceptShares.feature:162 apiShareManagementToShares/acceptShares.feature:175 apiShareManagementToShares/acceptShares.feature:196 -apiShareManagementToShares/acceptShares.feature:216 apiShareManagementToShares/acceptShares.feature:223 apiShareManagementToShares/acceptShares.feature:249 apiShareManagementToShares/acceptShares.feature:270 @@ -315,11 +314,6 @@ apiShareManagementBasicToShares/deleteShareFromShares.feature:182 apiShareManagementBasicToShares/deleteShareFromShares.feature:183 apiShareManagementBasicToShares/deleteShareFromShares.feature:184 # -# https://github.com/owncloud/ocis-reva/issues/260 Sharee retrieves the information about a share -but gets response containing all the shares -# -apiShareOperationsToShares/accessToShare.feature:55 -apiShareOperationsToShares/accessToShare.feature:56 -# # https://github.com/owncloud/ocis-reva/issues/262 Shares are not deleted when user is deleted # apiShareOperationsToShares/gettingShares.feature:24 diff --git a/tests/acceptance/expected-failures-on-OWNCLOUD-storage.txt b/tests/acceptance/expected-failures-on-OWNCLOUD-storage.txt index 90d9baaaa2..0312c9ce86 100644 --- a/tests/acceptance/expected-failures-on-OWNCLOUD-storage.txt +++ b/tests/acceptance/expected-failures-on-OWNCLOUD-storage.txt @@ -207,7 +207,6 @@ apiShareManagementToShares/acceptShares.feature:160 apiShareManagementToShares/acceptShares.feature:162 apiShareManagementToShares/acceptShares.feature:175 apiShareManagementToShares/acceptShares.feature:196 -apiShareManagementToShares/acceptShares.feature:216 apiShareManagementToShares/acceptShares.feature:223 apiShareManagementToShares/acceptShares.feature:249 apiShareManagementToShares/acceptShares.feature:270 @@ -305,11 +304,6 @@ apiShareManagementBasicToShares/deleteShareFromShares.feature:182 apiShareManagementBasicToShares/deleteShareFromShares.feature:183 apiShareManagementBasicToShares/deleteShareFromShares.feature:184 # -# https://github.com/owncloud/ocis-reva/issues/260 Sharee retrieves the information about a share -but gets response containing all the shares -# -apiShareOperationsToShares/accessToShare.feature:55 -apiShareOperationsToShares/accessToShare.feature:56 -# # https://github.com/owncloud/ocis-reva/issues/262 Shares are not deleted when user is deleted # apiShareOperationsToShares/gettingShares.feature:24 @@ -475,11 +469,6 @@ apiSharePublicLink1/createPublicLinkShare.feature:730 apiSharePublicLink1/createPublicLinkShare.feature:733 apiSharePublicLink1/createPublicLinkShare.feature:742 # -# https://github.com/owncloud/ocis-reva/issues/311 Deleting a public link after renaming a file -# -apiSharePublicLink1/deletePublicLinkShare.feature:37 -apiSharePublicLink1/deletePublicLinkShare.feature:38 -# # https://github.com/owncloud/ocis-reva/issues/373 copying a folder within a public link folder to folder with same name as an already existing file overwrites the parent file # apiSharePublicLink2/copyFromPublicLink.feature:60 diff --git a/tests/acceptance/features/apiOcisSpecific/apiShareOperations-accessToShare.feature b/tests/acceptance/features/apiOcisSpecific/apiShareOperations-accessToShare.feature deleted file mode 100644 index 4a6cd9a3ad..0000000000 --- a/tests/acceptance/features/apiOcisSpecific/apiShareOperations-accessToShare.feature +++ /dev/null @@ -1,40 +0,0 @@ -@api @files_sharing-app-required -Feature: sharing - - Background: - Given these users have been created with default attributes and without skeleton files: - | username | - | Alice | - | Brian | - And user "Alice" has uploaded file with content "text file 0" to "/textfile0.txt" - And user "Alice" has uploaded file with content "text file 1" to "/textfile1.txt" - And user "Brian" has uploaded file with content "text file 0" to "/textfile0.txt" - And user "Brian" has uploaded file with content "text file 1" to "/textfile1.txt" - - @issue-ocis-reva-260 - # after fixing all issues delete this Scenario and use the one from oC10 core - Scenario Outline: Sharee can't see the share that is filtered out - Given using OCS API version "" - And user "Alice" has shared file "textfile0.txt" with user "Brian" - And user "Alice" has shared file "textfile1.txt" with user "Brian" - When user "Brian" gets all the shares shared with him that are received as file "textfile0 (2).txt" using the provisioning API - Then the OCS status code should be "" - And the HTTP status code should be "200" - And the last share_id should be included in the response - Examples: - | ocs_api_version | ocs_status_code | - | 1 | 100 | - - @issue-ocis-reva-260 @skipOnOcis-OCIS-Storage - # after fixing all issues delete this Scenario and use the one from oC10 core - Scenario Outline: Sharee can't see the share that is filtered out - Given using OCS API version "" - And user "Alice" has shared file "textfile0.txt" with user "Brian" - And user "Alice" has shared file "textfile1.txt" with user "Brian" - When user "Brian" gets all the shares shared with him that are received as file "textfile0 (2).txt" using the provisioning API - Then the OCS status code should be "" - And the HTTP status code should be "200" - And the last share_id should be included in the response - Examples: - | ocs_api_version | ocs_status_code | - | 2 | 200 |