Show the path relative to the requesting user
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.
This commit is contained in:
parent
7d31ae9909
commit
7c040c0bf9
|
@ -100,15 +100,8 @@ class Share20OCS {
|
||||||
*/
|
*/
|
||||||
protected function formatShare(\OCP\Share\IShare $share) {
|
protected function formatShare(\OCP\Share\IShare $share) {
|
||||||
$sharedBy = $this->userManager->get($share->getSharedBy());
|
$sharedBy = $this->userManager->get($share->getSharedBy());
|
||||||
// for federated shares the owner can be a remote user, in this
|
$shareOwner = $this->userManager->get($share->getShareOwner());
|
||||||
// case we use the initiator
|
|
||||||
if ($this->userManager->userExists($share->getShareOwner())) {
|
|
||||||
$shareOwner = $this->userManager->get($share->getShareOwner());
|
|
||||||
$localUser = $share->getShareOwner();
|
|
||||||
} else {
|
|
||||||
$shareOwner = $this->userManager->get($share->getSharedBy());
|
|
||||||
$localUser = $share->getSharedBy();
|
|
||||||
}
|
|
||||||
$result = [
|
$result = [
|
||||||
'id' => $share->getId(),
|
'id' => $share->getId(),
|
||||||
'share_type' => $share->getShareType(),
|
'share_type' => $share->getShareType(),
|
||||||
|
@ -123,8 +116,16 @@ class Share20OCS {
|
||||||
'displayname_file_owner' => $shareOwner !== null ? $shareOwner->getDisplayName() : $share->getShareOwner(),
|
'displayname_file_owner' => $shareOwner !== null ? $shareOwner->getDisplayName() : $share->getShareOwner(),
|
||||||
];
|
];
|
||||||
|
|
||||||
$node = $share->getNode();
|
$userFolder = $this->rootFolder->getUserFolder($this->currentUser->getUID());
|
||||||
$result['path'] = $this->rootFolder->getUserFolder($localUser)->getRelativePath($node->getPath());
|
$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) {
|
if ($node instanceOf \OCP\Files\Folder) {
|
||||||
$result['item_type'] = 'folder';
|
$result['item_type'] = 'folder';
|
||||||
} else {
|
} else {
|
||||||
|
@ -536,7 +537,6 @@ class Share20OCS {
|
||||||
$shares = array_merge($shares, $federatedShares);
|
$shares = array_merge($shares, $federatedShares);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$formatted = [];
|
$formatted = [];
|
||||||
foreach ($shares as $share) {
|
foreach ($shares as $share) {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue