summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/api
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2016-05-11 20:48:27 +0200
committerBjörn Schießle <schiessle@owncloud.com>2016-05-20 21:15:15 +0200
commit7b25839bd51b3b6cd920209c254f014c03437113 (patch)
tree2e9885bdb068d56ff7bb9fde344c4da0cc95e2d3 /apps/files_sharing/api
parent81e3787f9cb4936f186b25e0dccb07b4e6dcce83 (diff)
downloadnextcloud-server-7b25839bd51b3b6cd920209c254f014c03437113.tar.gz
nextcloud-server-7b25839bd51b3b6cd920209c254f014c03437113.zip
use share initiator as fall back to access the file
in case of federated re-shares the owner can be a remote user. Therefore we can't always use to owner to access the local file
Diffstat (limited to 'apps/files_sharing/api')
-rw-r--r--apps/files_sharing/api/share20ocs.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/apps/files_sharing/api/share20ocs.php b/apps/files_sharing/api/share20ocs.php
index af762845326..28166b943b8 100644
--- a/apps/files_sharing/api/share20ocs.php
+++ b/apps/files_sharing/api/share20ocs.php
@@ -99,7 +99,15 @@ class Share20OCS {
*/
protected function formatShare(\OCP\Share\IShare $share) {
$sharedBy = $this->userManager->get($share->getSharedBy());
- $shareOwner = $this->userManager->get($share->getShareOwner());
+ // for federated shares the owner can be a remote user, in this
+ // 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 = [
'id' => $share->getId(),
'share_type' => $share->getShareType(),
@@ -115,7 +123,7 @@ class Share20OCS {
];
$node = $share->getNode();
- $result['path'] = $this->rootFolder->getUserFolder($share->getShareOwner())->getRelativePath($node->getPath());
+ $result['path'] = $this->rootFolder->getUserFolder($localUser)->getRelativePath($node->getPath());
if ($node instanceOf \OCP\Files\Folder) {
$result['item_type'] = 'folder';
} else {