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
This commit is contained in:
parent
7863987b19
commit
d41d5c48f0
|
@ -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 {
|
||||
|
|
|
@ -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]);
|
||||
|
|
Loading…
Reference in New Issue