diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2019-03-09 09:01:48 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2019-03-31 10:40:14 -0100 |
commit | 44c1feb938072fc7c3053b012335e5719cfc9762 (patch) | |
tree | 44a68f1869637f6e1d5ff6bc397b94a9e585de54 | |
parent | 0a1d2bf4946b514bbbb9c4481e030242ded4487a (diff) | |
download | nextcloud-server-44c1feb938072fc7c3053b012335e5719cfc9762.tar.gz nextcloud-server-44c1feb938072fc7c3053b012335e5719cfc9762.zip |
returns reshares in API
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareAPIController.php | 38 | ||||
-rw-r--r-- | lib/private/Share20/DefaultShareProvider.php | 2 |
2 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..6e92d653950 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_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)); $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_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)) { + continue; + } + try { - $formatted[] = $this->formatShare($share); - } catch (NotFoundException $e) { + $format = $this->formatShare($share, $folder); + + $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); } diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index 59aefd54cde..e58ae4f7c91 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -609,7 +609,7 @@ class DefaultShareProvider implements IShareProvider { */ public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset) { $qb = $this->dbConn->getQueryBuilder(); - $qb->select('*') + $qb->selectDistinct('*') ->from('share') ->andWhere($qb->expr()->orX( $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), |