Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions apps/files_sharing/lib/Controller/DeletedShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* @author John Molakvoæ <[email protected]>
* @author Julius Härtl <[email protected]>
* @author Roeland Jago Douma <[email protected]>
* @author Kate Döen <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
Expand All @@ -28,14 +29,18 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\Files_Sharing\Controller;

use OCA\Deck\Sharing\ShareAPIHelper;
use OCA\Files_Sharing\ResponseDefinitions;
use OCP\App\IAppManager;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCS\OCSNotFoundException;
use OCP\AppFramework\OCSController;
use OCP\AppFramework\QueryException;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\IGroupManager;
Expand Down Expand Up @@ -71,14 +76,14 @@ class DeletedShareAPIController extends OCSController {
private $serverContainer;

public function __construct(string $appName,
IRequest $request,
ShareManager $shareManager,
string $UserId,
IUserManager $userManager,
IGroupManager $groupManager,
IRootFolder $rootFolder,
IAppManager $appManager,
IServerContainer $serverContainer) {
IRequest $request,
ShareManager $shareManager,
string $UserId,
IUserManager $userManager,
IGroupManager $groupManager,
IRootFolder $rootFolder,
IAppManager $appManager,
IServerContainer $serverContainer) {
parent::__construct($appName, $request);

$this->shareManager = $shareManager;
Expand Down Expand Up @@ -121,7 +126,7 @@ private function formatShare(IShare $share): array {
}

$result['path'] = $userFolder->getRelativePath($node->getPath());
if ($node instanceof \OCP\Files\Folder) {
if ($node instanceof Folder) {
$result['item_type'] = 'folder';
} else {
$result['item_type'] = 'file';
Expand Down Expand Up @@ -166,6 +171,9 @@ private function formatShare(IShare $share): array {

/**
* @NoAdminRequired
*
* @psalm-import-type DeletedShareItem from ResponseDefinitions
* @return DataResponse<DeletedShareItem[]> 200
*/
public function index(): DataResponse {
$groupShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_GROUP, null, -1, 0);
Expand All @@ -184,7 +192,9 @@ public function index(): DataResponse {
/**
* @NoAdminRequired
*
* @return DataResponse 200
* @throws OCSException
* @throws OCSNotFoundException
*/
public function undelete(string $id): DataResponse {
try {
Expand Down Expand Up @@ -229,7 +239,7 @@ private function getRoomShareHelper() {
* If the Deck application is not enabled or the helper is not available
* a QueryException is thrown instead.
*
* @return \OCA\Deck\Sharing\ShareAPIHelper
* @return ShareAPIHelper
* @throws QueryException
*/
private function getDeckShareHelper() {
Expand Down
38 changes: 23 additions & 15 deletions apps/files_sharing/lib/Controller/RemoteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* @author Bjoern Schiessle <[email protected]>
* @author Joas Schilling <[email protected]>
* @author Roeland Jago Douma <[email protected]>
* @author Kate Döen <[email protected]>
*
* @license AGPL-3.0
*
Expand All @@ -21,9 +22,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

namespace OCA\Files_Sharing\Controller;

use OC\Files\View;
use OC_User;
use OCA\Files_Sharing\External\Manager;
use OCA\Files_Sharing\ResponseDefinitions;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSForbiddenException;
use OCP\AppFramework\OCS\OCSNotFoundException;
Expand All @@ -49,9 +54,9 @@ class RemoteController extends OCSController {
* @param Manager $externalManager
*/
public function __construct($appName,
IRequest $request,
Manager $externalManager,
ILogger $logger) {
IRequest $request,
Manager $externalManager,
ILogger $logger) {
parent::__construct($appName, $request);

$this->externalManager = $externalManager;
Expand All @@ -63,7 +68,8 @@ public function __construct($appName,
*
* Get list of pending remote shares
*
* @return DataResponse
* @psalm-import-type RemoteShareItem from ResponseDefinitions
* @return DataResponse<RemoteShareItem[]> 200
*/
public function getOpenShares() {
return new DataResponse($this->externalManager->getOpenShares());
Expand All @@ -75,10 +81,10 @@ public function getOpenShares() {
* Accept a remote share
*
* @param int $id
* @return DataResponse
* @return DataResponse 200
* @throws OCSNotFoundException
*/
public function acceptShare($id) {
public function acceptShare(int $id) {
if ($this->externalManager->acceptShare($id)) {
return new DataResponse();
}
Expand All @@ -95,10 +101,10 @@ public function acceptShare($id) {
* Decline a remote share
*
* @param int $id
* @return DataResponse
* @return DataResponse 200
* @throws OCSNotFoundException
*/
public function declineShare($id) {
public function declineShare(int $id) {
if ($this->externalManager->declineShare($id)) {
return new DataResponse();
}
Expand All @@ -114,7 +120,7 @@ public function declineShare($id) {
* @return array enriched share info with data from the filecache
*/
private static function extendShareInfo($share) {
$view = new \OC\Files\View('/' . \OC_User::getUser() . '/files/');
$view = new View('/' . OC_User::getUser() . '/files/');
$info = $view->getFileInfo($share['mountpoint']);

if ($info === false) {
Expand All @@ -135,7 +141,8 @@ private static function extendShareInfo($share) {
*
* List accepted remote shares
*
* @return DataResponse
* @psalm-import-type RemoteShareItem from ResponseDefinitions
* @return DataResponse<RemoteShareItem[]> 200
*/
public function getShares() {
$shares = $this->externalManager->getAcceptedShares();
Expand All @@ -150,10 +157,11 @@ public function getShares() {
* Get info of a remote share
*
* @param int $id
* @return DataResponse
* @psalm-import-type RemoteShareItem from ResponseDefinitions
* @return DataResponse<RemoteShareItem> 200
* @throws OCSNotFoundException
*/
public function getShare($id) {
public function getShare(int $id) {
$shareInfo = $this->externalManager->getShare($id);

if ($shareInfo === false) {
Expand All @@ -170,18 +178,18 @@ public function getShare($id) {
* Unshare a remote share
*
* @param int $id
* @return DataResponse
* @return DataResponse 200
* @throws OCSNotFoundException
* @throws OCSForbiddenException
*/
public function unshare($id) {
public function unshare(int $id) {
$shareInfo = $this->externalManager->getShare($id);

if ($shareInfo === false) {
throw new OCSNotFoundException('Share does not exist');
}

$mountPoint = '/' . \OC_User::getUser() . '/files' . $shareInfo['mountpoint'];
$mountPoint = '/' . OC_User::getUser() . '/files' . $shareInfo['mountpoint'];

if ($this->externalManager->removeShare($mountPoint) === true) {
return new DataResponse();
Expand Down
Loading