diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2019-04-02 23:59:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-02 23:59:02 +0300 |
commit | b365840004028c2035d0da3d78da7ae692eff187 (patch) | |
tree | ec1c0569f506da28cf941623f183e2f63c0da201 /apps | |
parent | cffa71ab33cf0be0977766360d391b30dd44ec11 (diff) | |
parent | 586a3a14a95b05e52d270322d380a8f5b56a1e2f (diff) |
Merge pull request #14605 from nextcloud/bugfix/14112/display-reshares
returns reshares in API
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareAPIController.php | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 797558fbd9a..a6ad70a7f4b 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -627,27 +627,47 @@ class ShareAPIController extends OCSController { /** @var \OCP\Share\IShare[] $shares */ $shares = []; foreach ($nodes as $node) { - $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_USER, $node, false, -1, 0)); - $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_GROUP, $node, false, -1, 0)); - $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_LINK, $node, false, -1, 0)); - if($this->shareManager->shareProviderExists(Share::SHARE_TYPE_EMAIL)) { - $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_EMAIL, $node, false, -1, 0)); + + $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_USER, $node, true, -1, 0)); + $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_GROUP, $node, true, -1, 0)); + $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_LINK, $node, true, -1, 0)); + if ($this->shareManager->shareProviderExists(Share::SHARE_TYPE_EMAIL)) { + $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_EMAIL, $node, true, -1, 0)); } if ($this->shareManager->outgoingServer2ServerSharesAllowed()) { - $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_REMOTE, $node, false, -1, 0)); + $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_REMOTE, $node, true, -1, 0)); } - $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_ROOM, $node, false, -1, 0)); + $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, Share::SHARE_TYPE_ROOM, $node, true, -1, 0)); } - $formatted = []; + $formatted = $miniFormatted = []; + $resharingRight = false; + $known = []; foreach ($shares as $share) { + if (in_array($share->getId(), $known) || $share->getSharedWith() === $this->currentUser) { + continue; + } + try { - $formatted[] = $this->formatShare($share); - } catch (NotFoundException $e) { + $format = $this->formatShare($share); + + $known[] = $share->getId(); + $formatted[] = $format; + if ($share->getSharedBy() === $this->currentUser) { + $miniFormatted[] = $format; + } + if (!$resharingRight && $this->shareProviderResharingRights($this->currentUser, $share, $folder)) { + $resharingRight = true; + } + } catch (\Exception $e) { //Ignore this share } } + if (!$resharingRight) { + $formatted = $miniFormatted; + } + return new DataResponse($formatted); } |