Skip to content

Commit

Permalink
fix(DefaultShareProvider): Correctly filter reshares
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin committed Jan 15, 2025
1 parent 69b4a6c commit 74a8f40
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
7 changes: 7 additions & 0 deletions build/integration/features/bootstrap/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,13 @@ public function checkSharedUserNotInResponse($user) {
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) {
Expand Down
28 changes: 28 additions & 0 deletions build/integration/sharing_features/sharing-v1-part2.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 6 additions & 8 deletions lib/private/Share20/DefaultShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -706,14 +706,12 @@ public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offs
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) {
Expand Down

0 comments on commit 74a8f40

Please sign in to comment.