diff options
author | Robin Appelman <robin@icewind.nl> | 2016-09-20 17:59:04 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2016-10-12 16:12:35 +0200 |
commit | 1b3b816a0a2ffb80d2495cd7394988e689351c47 (patch) | |
tree | 06e6ec193f61c73529c814f0f818715cb81c3584 | |
parent | 3845d4ec9a7a84cda4f2fe5fbb4a65e90dfe21ff (diff) | |
download | nextcloud-server-1b3b816a0a2ffb80d2495cd7394988e689351c47.tar.gz nextcloud-server-1b3b816a0a2ffb80d2495cd7394988e689351c47.zip |
re-use the share node while formating if we already have it
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r-- | apps/files_sharing/lib/API/Share20OCS.php | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/apps/files_sharing/lib/API/Share20OCS.php b/apps/files_sharing/lib/API/Share20OCS.php index 5adfa640c00..4ec4a006be2 100644 --- a/apps/files_sharing/lib/API/Share20OCS.php +++ b/apps/files_sharing/lib/API/Share20OCS.php @@ -29,6 +29,7 @@ use OCP\AppFramework\OCS\OCSException; use OCP\AppFramework\OCS\OCSForbiddenException; use OCP\AppFramework\OCS\OCSNotFoundException; use OCP\AppFramework\OCSController; +use OCP\Files\Node; use OCP\Files\NotFoundException; use OCP\IGroupManager; use OCP\IL10N; @@ -110,10 +111,11 @@ class Share20OCS extends OCSController { * Convert an IShare to an array for OCS output * * @param \OCP\Share\IShare $share + * @param Node|null $recipientNode * @return array * @throws NotFoundException In case the node can't be resolved. */ - protected function formatShare(\OCP\Share\IShare $share) { + protected function formatShare(\OCP\Share\IShare $share, Node $recipientNode = null) { $sharedBy = $this->userManager->get($share->getSharedBy()); $shareOwner = $this->userManager->get($share->getShareOwner()); @@ -132,13 +134,17 @@ class Share20OCS extends OCSController { ]; $userFolder = $this->rootFolder->getUserFolder($this->currentUser->getUID()); - $nodes = $userFolder->getById($share->getNodeId()); + if ($recipientNode) { + $node = $recipientNode; + } else { + $nodes = $userFolder->getById($share->getNodeId()); - if (empty($nodes)) { - throw new NotFoundException(); - } + if (empty($nodes)) { + throw new NotFoundException(); + } - $node = $nodes[0]; + $node = $nodes[0]; + } $result['path'] = $userFolder->getRelativePath($node->getPath()); if ($node instanceOf \OCP\Files\Folder) { @@ -543,7 +549,7 @@ class Share20OCS extends OCSController { $formatted = []; foreach ($shares as $share) { try { - $formatted[] = $this->formatShare($share); + $formatted[] = $this->formatShare($share, $path); } catch (NotFoundException $e) { //Ignore share } |