From a24e7f655885b5047e73036acb2f1706803a2b65 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 29 Jan 2016 15:26:04 +0100 Subject: Add path filter to OCS Share API ?shared_with_me=true This allows all clients to quickly get the share info for a given path. Instead of returning everything and filtering it then manually on the client side. --- apps/files_sharing/api/share20ocs.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'apps/files_sharing/api/share20ocs.php') diff --git a/apps/files_sharing/api/share20ocs.php b/apps/files_sharing/api/share20ocs.php index 2dadc0888ec..8fe8991f9c9 100644 --- a/apps/files_sharing/api/share20ocs.php +++ b/apps/files_sharing/api/share20ocs.php @@ -329,9 +329,13 @@ class Share20OCS { return new \OC_OCS_Result($share); } - private function getSharedWithMe() { - $userShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_USER, -1, 0); - $groupShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, -1, 0); + /** + * @param \OCP\Files\File|\OCP\Files\Folder $node + * @return \OC_OCS_Result + */ + private function getSharedWithMe($node = null) { + $userShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $node, -1, 0); + $groupShares = $this->shareManager->getSharedWith($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $node, -1, 0); $shares = array_merge($userShares, $groupShares); @@ -390,10 +394,6 @@ class Share20OCS { $subfiles = $this->request->getParam('subfiles'); $path = $this->request->getParam('path', null); - if ($sharedWithMe === 'true') { - return $this->getSharedWithMe(); - } - if ($path !== null) { $userFolder = $this->rootFolder->getUserFolder($this->currentUser->getUID()); try { @@ -403,6 +403,10 @@ class Share20OCS { } } + if ($sharedWithMe === 'true') { + return $this->getSharedWithMe($path); + } + if ($subfiles === 'true') { return $this->getSharesInDir($path); } -- cgit v1.2.3