]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix getting recipient share in ocs api
authorRobin Appelman <robin@icewind.nl>
Wed, 21 Sep 2016 15:35:09 +0000 (17:35 +0200)
committerRobin Appelman <robin@icewind.nl>
Wed, 12 Oct 2016 14:12:37 +0000 (16:12 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
apps/files_sharing/lib/API/Share20OCS.php

index 4ec4a006be2b67d9c3d3e2c66f49d052dd14cbce..d5a6d8bc9db3984fe17ee5b6ee69a655fa1c3e8a 100644 (file)
@@ -85,15 +85,15 @@ class Share20OCS extends OCSController {
         * @param IL10N $l10n
         */
        public function __construct(
-                       $appName,
-                       IRequest $request,
-                       IManager $shareManager,
-                       IGroupManager $groupManager,
-                       IUserManager $userManager,
-                       IRootFolder $rootFolder,
-                       IURLGenerator $urlGenerator,
-                       IUser $currentUser,
-                       IL10N $l10n
+               $appName,
+               IRequest $request,
+               IManager $shareManager,
+               IGroupManager $groupManager,
+               IUserManager $userManager,
+               IRootFolder $rootFolder,
+               IURLGenerator $urlGenerator,
+               IUser $currentUser,
+               IL10N $l10n
        ) {
                parent::__construct($appName, $request);
 
@@ -405,6 +405,8 @@ class Share20OCS extends OCSController {
 
                try {
                        $share = $this->shareManager->createShare($share);
+                       $userFolder = $this->rootFolder->getUserFolder($this->currentUser->getUID());
+                       $recipientNode = $userFolder->get($share->getTarget());
                } catch (GenericShareException $e) {
                        $code = $e->getCode() === 0 ? 403 : $e->getCode();
                        throw new OCSException($e->getHint(), $code);
@@ -414,7 +416,7 @@ class Share20OCS extends OCSController {
                        $share->getNode()->unlock(ILockingProvider::LOCK_SHARED);
                }
 
-               $output = $this->formatShare($share);
+               $output = $this->formatShare($share, $recipientNode);
 
                return new DataResponse($output);
        }
@@ -429,7 +431,7 @@ class Share20OCS extends OCSController {
 
                $shares = array_merge($userShares, $groupShares);
 
-               $shares = array_filter($shares, function(IShare $share) {
+               $shares = array_filter($shares, function (IShare $share) {
                        return $share->getShareOwner() !== $this->currentUser->getUID();
                });
 
@@ -716,7 +718,8 @@ class Share20OCS extends OCSController {
 
                // If the share is shared with you (or a group you are a member of)
                if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER &&
-                       $share->getSharedWith() === $this->currentUser->getUID()) {
+                       $share->getSharedWith() === $this->currentUser->getUID()
+               ) {
                        return true;
                }
 
@@ -751,7 +754,7 @@ class Share20OCS extends OCSController {
                        throw new \Exception('Invalid date. Format must be YYYY-MM-DD');
                }
 
-               $date->setTime(0,0,0);
+               $date->setTime(0, 0, 0);
 
                return $date;
        }
@@ -769,7 +772,7 @@ class Share20OCS extends OCSController {
 
                // First check if it is an internal share.
                try {
-                       $share = $this->shareManager->getShareById('ocinternal:'.$id);
+                       $share = $this->shareManager->getShareById('ocinternal:' . $id);
                } catch (ShareNotFound $e) {
                        if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
                                throw new ShareNotFound();
@@ -783,6 +786,7 @@ class Share20OCS extends OCSController {
 
        /**
         * Lock a Node
+        *
         * @param \OCP\Files\Node $node
         */
        private function lock(\OCP\Files\Node $node) {