diff options
author | provokateurin <kate@provokateurin.de> | 2024-12-10 14:45:15 +0100 |
---|---|---|
committer | provokateurin <kate@provokateurin.de> | 2025-01-15 09:43:40 +0100 |
commit | 74a8f40251c6f4317f119f8ccb21d2e506517db7 (patch) | |
tree | 05b72efcafd564a657195833b50ed06494ab6a84 | |
parent | 69b4a6cc19683769a92ebbdb0a687cde48ad0ffb (diff) | |
download | nextcloud-server-fix/defaultshareprovider/filter-reshares-correctly.tar.gz nextcloud-server-fix/defaultshareprovider/filter-reshares-correctly.zip |
fix(DefaultShareProvider): Correctly filter resharesfix/defaultshareprovider/filter-reshares-correctly
Signed-off-by: provokateurin <kate@provokateurin.de>
-rw-r--r-- | build/integration/features/bootstrap/Sharing.php | 7 | ||||
-rw-r--r-- | build/integration/sharing_features/sharing-v1-part2.feature | 28 | ||||
-rw-r--r-- | lib/private/Share20/DefaultShareProvider.php | 14 |
3 files changed, 41 insertions, 8 deletions
diff --git a/build/integration/features/bootstrap/Sharing.php b/build/integration/features/bootstrap/Sharing.php index a58a1b4fda3..bb8af3a046f 100644 --- a/build/integration/features/bootstrap/Sharing.php +++ b/build/integration/features/bootstrap/Sharing.php @@ -373,6 +373,13 @@ trait Sharing { Assert::assertEquals(false, $this->isFieldInResponse('share_with', "$user")); } + /** + * @Then /^Share type "([^"]*)" should not be included in the response$/ + */ + public function checkShareTypeNotInResponse(int $shareType) { + Assert::assertEquals(false, $this->isFieldInResponse('share_type', $shareType)); + } + public function isUserOrGroupInSharedData($userOrGroup, $permissions = null) { $data = simplexml_load_string($this->response->getBody())->data[0]; foreach ($data as $element) { diff --git a/build/integration/sharing_features/sharing-v1-part2.feature b/build/integration/sharing_features/sharing-v1-part2.feature index 8cc97fe71ee..7ea21a96750 100644 --- a/build/integration/sharing_features/sharing-v1-part2.feature +++ b/build/integration/sharing_features/sharing-v1-part2.feature @@ -23,6 +23,34 @@ Feature: sharing And User "user2" should be included in the response And User "user3" should not be included in the response + Scenario: getting all shares of a file with reshares with link share + Given user "user0" exists + And user "user1" exists + When as "user0" creating a share with + | path | textfile0.txt | + | shareType | 0 | + | shareWith | user1 | + Then the OCS status code should be "100" + And the HTTP status code should be "200" + When as "user0" creating a share with + | path | textfile0.txt | + | shareType | 3 | + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And last link share can be downloaded + When As an "user1" + And sending "GET" to "/apps/files_sharing/api/v1/shares?reshares=true&path=textfile0 (2).txt" + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And User "user1" should not be included in the response + And Share type "3" should not be included in the response + When As an "user1" + And sending "GET" to "/apps/files_sharing/api/v1/shares?shared_with_me=true&path=textfile0 (2).txt" + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And User "user1" should be included in the response + And Share type "3" should not be included in the response + Scenario: getting all shares of a file with a received share after revoking the resharing rights Given user "user0" exists And user "user1" exists diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index ca3c33d6dbb..ad1e447c04f 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -706,14 +706,12 @@ class DefaultShareProvider implements IShareProviderWithNotification, IShareProv if ($reshares === false) { $qb->andWhere($qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId))); } else { - if ($node === null) { - $qb->andWhere( - $qb->expr()->orX( - $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)), - $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)) - ) - ); - } + $qb->andWhere( + $qb->expr()->orX( + $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)), + $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)) + ) + ); } if ($node !== null) { |