Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorRoeland Douma <rullzer@users.noreply.github.com>2016-06-13 13:47:21 +0300
committerThomas Müller <DeepDiver1975@users.noreply.github.com>2016-06-13 13:47:21 +0300
commitd41d5c48f01512b63eea25f1d7b8d8e508096ac5 (patch)
tree1a82c6f90aa5c878ccdfdd3b47055db20237699c /apps
parent7863987b19bafe5939cc4ebf801688e5c361fbdd (diff)
Show the path relative to the requesting user (#25067)
A share can only be requested by 3 'types' of people * owner * initiator * recipient So we have to get the path as the current user. Since that is the only path that has any meaning to the user. - Fixed tests
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/api/share20ocs.php12
-rw-r--r--apps/files_sharing/tests/api/share20ocstest.php21
2 files changed, 28 insertions, 5 deletions
diff --git a/apps/files_sharing/api/share20ocs.php b/apps/files_sharing/api/share20ocs.php
index 1aeec1e1ccb..bbd0e04b432 100644
--- a/apps/files_sharing/api/share20ocs.php
+++ b/apps/files_sharing/api/share20ocs.php
@@ -103,8 +103,16 @@ class Share20OCS {
'displayname_file_owner' => $shareOwner !== null ? $shareOwner->getDisplayName() : $share->getShareOwner(),
];
- $node = $share->getNode();
- $result['path'] = $this->rootFolder->getUserFolder($share->getShareOwner())->getRelativePath($node->getPath());
+ $userFolder = $this->rootFolder->getUserFolder($this->currentUser->getUID());
+ $nodes = $userFolder->getById($share->getNodeId());
+
+ if (empty($nodes)) {
+ throw new NotFoundException();
+ }
+
+ $node = $nodes[0];
+ $result['path'] = $userFolder->getRelativePath($node->getPath());
+
if ($node instanceOf \OCP\Files\Folder) {
$result['item_type'] = 'folder';
} else {
diff --git a/apps/files_sharing/tests/api/share20ocstest.php b/apps/files_sharing/tests/api/share20ocstest.php
index 42a23b43ce1..5b1f729997f 100644
--- a/apps/files_sharing/tests/api/share20ocstest.php
+++ b/apps/files_sharing/tests/api/share20ocstest.php
@@ -378,8 +378,12 @@ class Share20OCSTest extends \Test\TestCase {
->method('getRelativePath')
->will($this->returnArgument(0));
+ $userFolder->method('getById')
+ ->with($share->getNodeId())
+ ->willReturn([$share->getNode()]);
+
$this->rootFolder->method('getUserFolder')
- ->with($share->getShareOwner())
+ ->with($this->currentUser->getUID())
->willReturn($userFolder);
$this->urlGenerator
@@ -1869,8 +1873,19 @@ class Share20OCSTest extends \Test\TestCase {
->willReturn('myLink');
- $this->rootFolder->method('getUserFolder')->with($share->getShareOwner())->will($this->returnSelf());
- $this->rootFolder->method('getRelativePath')->will($this->returnArgument(0));
+ $this->rootFolder->method('getUserFolder')
+ ->with($this->currentUser->getUID())
+ ->will($this->returnSelf());
+
+ if (!$exception) {
+ $this->rootFolder->method('getById')
+ ->with($share->getNodeId())
+ ->willReturn([$share->getNode()]);
+
+ $this->rootFolder->method('getRelativePath')
+ ->with($share->getNode()->getPath())
+ ->will($this->returnArgument(0));
+ }
try {
$result = $this->invokePrivate($this->ocs, 'formatShare', [$share]);