diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2015-10-01 15:41:24 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2015-10-02 07:41:57 +0200 |
commit | c3e7d324c5e61eb087fb2ea5102d332f9f08db3d (patch) | |
tree | 6c9adf8048a1a695043dea7e9f5f595420f7f0ea /apps/files_sharing/api | |
parent | 0d3009951fe801f9c0d4599694638446166b4ee5 (diff) | |
download | nextcloud-server-c3e7d324c5e61eb087fb2ea5102d332f9f08db3d.tar.gz nextcloud-server-c3e7d324c5e61eb087fb2ea5102d332f9f08db3d.zip |
Extend share info
The data from the share_external is not to much. Thus we enrich this
data with info from the filecache.
This allows endpoints using this to actually show usefull information.
The filecache might not be up to date but that is a sacrifice we need to
make in terms of speed. Else the number of remote PROPFINDS grows
lineary with the number of remote shares wich will make this endpoint
practically unusable.
Diffstat (limited to 'apps/files_sharing/api')
-rw-r--r-- | apps/files_sharing/api/remote.php | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/apps/files_sharing/api/remote.php b/apps/files_sharing/api/remote.php index ab87820611c..76f9babcd19 100644 --- a/apps/files_sharing/api/remote.php +++ b/apps/files_sharing/api/remote.php @@ -92,6 +92,23 @@ class Remote { } /** + * @param array $share Share with info from the share_external table + * @return enriched share info with data from the filecache + */ + private static function extendShareInfo($share) { + $view = new \OC\Files\View('/' . \OC_User::getUser() . '/files/'); + $info = $view->getFileInfo($shares['mountpoint']); + + $share['mimetype'] = $info->getMimetype(); + $share['mtime'] = $info->getMtime(); + $share['permissions'] = $info->getPermissions(); + $share['type'] = $info->getType(); + $share['file_id'] = $info->getId(); + + return $share; + } + + /** * List accepted remote shares * * @param array $params @@ -106,8 +123,12 @@ class Remote { \OC::$server->getNotificationManager(), \OC_User::getUser() ); + + $shares = $externalManager->getAcceptedShares(); + + $shares = array_map('self::extendShareInfo', $shares); - return new \OC_OCS_Result($externalManager->getAcceptedShares()); + return new \OC_OCS_Result($shares); } /** @@ -131,6 +152,7 @@ class Remote { if ($shareInfo === false) { return new \OC_OCS_Result(null, 404, 'share does not exist'); } else { + $shareInfo = self::extendShareInfo($shareInfo); return new \OC_OCS_Result($shareInfo); } } |