diff --git a/apps/files_sharing/api/customlocal.php b/apps/files_sharing/api/customlocal.php index e838fec01e18..3e5fdb2a3948 100644 --- a/apps/files_sharing/api/customlocal.php +++ b/apps/files_sharing/api/customlocal.php @@ -132,7 +132,7 @@ public static function createShare($params) } $token = 0; - + $id = false; try { if(!$executor->checkFileIntegrity()) { @@ -147,7 +147,7 @@ public static function createShare($params) throw new \Exception('Check share target failed'); } - $executor->insertShare(); + $id = $executor->insertShare(); $token = $executor->getInsertResult(); } catch (\Exception $e) { @@ -157,39 +157,15 @@ public static function createShare($params) if($token) { $data = []; - $username = \OCP\User::getUser(); - $queryStorages = \OC_DB::prepare('SELECT numeric_id FROM oc_storages WHERE id = ?'); - $resultStorages = $queryStorages->execute(['object::user:'.$username]); - $storageId = $resultStorages->fetchRow()['numeric_id']; - - $rows = []; + $data['id'] = $id; if(is_string($token)) { - $query = \OC_DB::prepare('SELECT * FROM oc_share WHERE token = ?'); - $result = $query->execute([$token]); - $rows = $result->fetchAll(); - } - else - { - $rows = self::getAllFilesSharedByMe(); - } - - foreach($rows as $key => $row) - { - // Only return information if the asker is the same person who shared the file - if($token === $row['token'] || ($share['share_with'] === $shareWith && $share['share_type'] === $shareType)) - { - $data['id'] = $row['id']; - if(is_string($token)) - { - $url = \OCP\Util::linkToPublic('files&t='.$token); - $data['url'] = $url; // '&' gets encoded to $amp; - $data['token'] = $token; - } - - return new \OC_OCS_Result([$data]); - } + $url = \OCP\Util::linkToPublic('files&t='.$token); + $data['url'] = $url; // '&' gets encoded to $amp; + $data['token'] = $token; } + + return new \OC_OCS_Result([$data]); } else {