diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/federatedfilesharing/appinfo/routes.php | 4 | ||||
-rw-r--r-- | apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php (renamed from apps/federatedfilesharing/lib/Controller/SaveToNextcloudController.php) | 23 | ||||
-rw-r--r-- | apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php (renamed from apps/federatedfilesharing/tests/Controller/SaveToNextcloudControllerTest.php) | 19 | ||||
-rw-r--r-- | apps/files_sharing/js/public.js | 10 |
4 files changed, 31 insertions, 25 deletions
diff --git a/apps/federatedfilesharing/appinfo/routes.php b/apps/federatedfilesharing/appinfo/routes.php index c5822c6b653..ec7b662686f 100644 --- a/apps/federatedfilesharing/appinfo/routes.php +++ b/apps/federatedfilesharing/appinfo/routes.php @@ -21,7 +21,7 @@ return [ 'routes' => [ - ['name' => 'SaveToNextcloud#saveToNextcloud', 'url' => '/saveToNextcloud', 'verb' => 'POST'], - ['name' => 'SaveToNextcloud#askForFederatedShare', 'url' => '/askForFederatedShare', 'verb' => 'POST'], + ['name' => 'MountPublicLink#createFederatedShare', 'url' => '/createFederatedShare', 'verb' => 'POST'], + ['name' => 'MountPublicLink#askForFederatedShare', 'url' => '/askForFederatedShare', 'verb' => 'POST'], ] ]; diff --git a/apps/federatedfilesharing/lib/Controller/SaveToNextcloudController.php b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php index c95b50ecf46..ec70090f97a 100644 --- a/apps/federatedfilesharing/lib/Controller/SaveToNextcloudController.php +++ b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php @@ -37,7 +37,14 @@ use OCP\ISession; use OCP\IUserSession; use OCP\Share\IManager; -class SaveToNextcloudController extends Controller { +/** + * Class MountPublicLinkController + * + * convert public links to federated shares + * + * @package OCA\FederatedFileSharing\Controller + */ +class MountPublicLinkController extends Controller { /** @var FederatedShareProvider */ private $federatedShareProvider; @@ -61,7 +68,7 @@ class SaveToNextcloudController extends Controller { private $clientService; /** - * SaveToNextcloudController constructor. + * MountPublicLinkController constructor. * * @param string $appName * @param IRequest $request @@ -95,8 +102,7 @@ class SaveToNextcloudController extends Controller { } /** - * save public link to my Nextcloud by asking the owner to create a federated - * share with me + * send federated share to a user of a public link * * @NoCSRFRequired * @PublicPage @@ -106,7 +112,7 @@ class SaveToNextcloudController extends Controller { * @param string $password * @return JSONResponse */ - public function saveToNextcloud($shareWith, $token, $password = '') { + public function createFederatedShare($shareWith, $token, $password = '') { try { list(, $server) = $this->addressHandler->splitUserRemote($shareWith); @@ -147,7 +153,7 @@ class SaveToNextcloudController extends Controller { * @param string $name (only for legacy reasons, can be removed with legacyMountPublicLink()) * @return JSONResponse */ - public function askForFederatedShare($token, $remote, $password = '', $owner='', $ownerDisplayName = '', $name = '') { + public function askForFederatedShare($token, $remote, $password = '', $owner = '', $ownerDisplayName = '', $name = '') { // check if server admin allows to mount public links from other servers if ($this->federatedShareProvider->isIncomingServer2serverShareEnabled() === false) { return new JSONResponse(['message' => $this->l->t('Server to server sharing is not enabled on this server')], Http::STATUS_BAD_REQUEST); @@ -158,14 +164,15 @@ class SaveToNextcloudController extends Controller { $httpClient = $this->clientService->newClient(); try { - $response = $httpClient->post($remote . '/index.php/apps/federatedfilesharing/saveToNextcloud', + $response = $httpClient->post($remote . '/index.php/apps/federatedfilesharing/createFederatedShare', [ 'body' => [ 'token' => $token, 'shareWith' => rtrim($shareWith, '/'), 'password' => $password - ] + ], + 'connect_timeout' => 10, ] ); } catch (\Exception $e) { diff --git a/apps/federatedfilesharing/tests/Controller/SaveToNextcloudControllerTest.php b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php index a98e4e4d09e..816fc90c4e1 100644 --- a/apps/federatedfilesharing/tests/Controller/SaveToNextcloudControllerTest.php +++ b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php @@ -4,7 +4,7 @@ * * @copyright Copyright (c) 2016, ownCloud, Inc. * @copyright Copyright (c) 2016, Björn Schießle <bjoern@schiessle.org> - * + * * @license AGPL-3.0 * * This code is free software: you can redistribute it and/or modify @@ -26,7 +26,7 @@ namespace OCA\FederatedFileSharing\Tests\Controller; use OC\HintException; use OCA\FederatedFileSharing\AddressHandler; -use OCA\FederatedFileSharing\Controller\SaveToNextcloudController; +use OCA\FederatedFileSharing\Controller\MountPublicLinkController; use OCA\FederatedFileSharing\FederatedShareProvider; use OCP\AppFramework\Http; use OCP\Files\IRootFolder; @@ -35,13 +35,12 @@ use OCP\IL10N; use OCP\ISession; use OCP\IUserManager; use OCP\IUserSession; -use OCP\Share; use OCP\Share\IManager; use OCP\Share\IShare; -class SaveToNextcloudControllerTest extends \Test\TestCase { +class MountPublicLinkControllerTest extends \Test\TestCase { - /** @var SaveToNextcloudController */ + /** @var MountPublicLinkController */ private $controller; /** @var \OCP\IRequest | \PHPUnit_Framework_MockObject_MockObject */ @@ -94,7 +93,7 @@ class SaveToNextcloudControllerTest extends \Test\TestCase { $this->userSession = $this->getMockBuilder('OCP\IUserSession')->disableOriginalConstructor()->getMock(); $this->clientService = $this->getMockBuilder('OCP\Http\Client\IClientService')->disableOriginalConstructor()->getMock(); - $this->controller = new SaveToNextcloudController( + $this->controller = new MountPublicLinkController( 'federatedfilesharing', $this->request, $this->federatedShareProvider, $this->shareManager, @@ -107,7 +106,7 @@ class SaveToNextcloudControllerTest extends \Test\TestCase { } /** - * @dataProvider dataTestSaveToNextcloud + * @dataProvider dataTestCreateFederatedShare * * @param string $shareWith * @param bool $validShareWith @@ -116,7 +115,7 @@ class SaveToNextcloudControllerTest extends \Test\TestCase { * @param bool $createSuccessful * @param string $expectedReturnData */ - public function testSaveToNextcloud($shareWith, $validShareWith, $token, $validToken, $createSuccessful, $expectedReturnData) { + public function testCreateFederatedShare($shareWith, $validShareWith, $token, $validToken, $createSuccessful, $expectedReturnData) { $this->addressHandler->expects($this->any())->method('splitUserRemote') ->with($shareWith) ->willReturnCallback( @@ -153,7 +152,7 @@ class SaveToNextcloudControllerTest extends \Test\TestCase { } ); - $result = $this->controller->saveToNextcloud($shareWith, $token); + $result = $this->controller->createFederatedShare($shareWith, $token); $errorCase = !$validShareWith || !$validToken || !$createSuccessful; @@ -170,7 +169,7 @@ class SaveToNextcloudControllerTest extends \Test\TestCase { } - public function dataTestSaveToNextcloud() { + public function dataTestCreateFederatedShare() { return [ //shareWith, validShareWith, token, validToken, createSuccessful, expectedReturnData ['user@server', true, 'token', true, true, 'server'], diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index 5746f4dbb8c..0dfff235998 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -248,7 +248,7 @@ OCA.Sharing.PublicApp = { var ownerDisplayName = $('#save').data('owner-display-name'); var name = $('#save').data('name'); var isProtected = $('#save').data('protected') ? 1 : 0; - OCA.Sharing.PublicApp._saveToNextcloud(remote, token, owner, ownerDisplayName, name, isProtected); + OCA.Sharing.PublicApp._createFederatedShare(remote, token, owner, ownerDisplayName, name, isProtected); }); $('#remote_address').on("keyup paste", function() { @@ -308,7 +308,7 @@ OCA.Sharing.PublicApp = { * @param isProtected * @private */ - _legacySaveToNextcloud: function (remote, token, owner, ownerDisplayName, name, isProtected) { + _legacyCreateFederatedShare: function (remote, token, owner, ownerDisplayName, name, isProtected) { var location = window.location.protocol + '//' + window.location.host + OC.webroot; @@ -336,7 +336,7 @@ OCA.Sharing.PublicApp = { } }, - _saveToNextcloud: function (remote, token, owner, ownerDisplayName, name, isProtected) { + _createFederatedShare: function (remote, token, owner, ownerDisplayName, name, isProtected) { var toggleLoading = function() { var iconClass = $('#save-button-confirm').attr('class'); @@ -358,13 +358,13 @@ OCA.Sharing.PublicApp = { toggleLoading(); if (remote.indexOf('@') === -1) { - this._legacySaveToNextcloud(remote, token, owner, ownerDisplayName, name, isProtected); + this._legacyCreateFederatedShare(remote, token, owner, ownerDisplayName, name, isProtected); toggleLoading(); return; } $.post( - OC.generateUrl('/apps/federatedfilesharing/saveToNextcloud'), + OC.generateUrl('/apps/federatedfilesharing/createFederatedShare'), { 'shareWith': remote, 'token': token |