diff --git a/apps/files_sharing/lib/api.php b/apps/files_sharing/lib/api.php index 21fd5d00a4ce227c1c79f2093323e1824d610e6a..10b3f76db8f998b6f535d1c415ba8fa3041e6f4d 100644 --- a/apps/files_sharing/lib/api.php +++ b/apps/files_sharing/lib/api.php @@ -31,6 +31,9 @@ class Api { * @return \OC_OCS_Result share information */ public static function getAllShares($params) { + if (isset($_GET['shared_with_me']) && $_GET['shared_with_me'] !== 'false') { + return self::getFilesSharedWithMe(); + } // if a file is specified, get the share for this file if (isset($_GET['path'])) { $params['itemSource'] = self::getFileId($_GET['path']); @@ -195,6 +198,22 @@ class Api { return new \OC_OCS_Result($result); } + /** + * get files shared with the user + * @return \OC_OCS_Result + */ + private static function getFilesSharedWithMe() { + try { + $shares = \OCP\Share::getItemsSharedWith('file'); + $result = new \OC_OCS_Result($shares); + } catch (\Exception $e) { + $result = new \OC_OCS_Result(null, 403, $e->getMessage()); + } + + return $result; + + } + /** * create a new share * @param array $params