summaryrefslogtreecommitdiffstats
path: root/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2017-01-27 12:52:17 +0100
committerRobin Appelman <robin@icewind.nl>2017-02-08 15:17:02 +0100
commitfa49c4a13b6c5455b13ad44cfc158b271aa9b616 (patch)
tree1014b6de1bd3761e2e26467c78c6f5fd4697ea56 /apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
parent1a591cea97313b8500154d6c2c9ce3aaf2f38a88 (diff)
downloadnextcloud-server-fa49c4a13b6c5455b13ad44cfc158b271aa9b616.tar.gz
nextcloud-server-fa49c4a13b6c5455b13ad44cfc158b271aa9b616.zip
Add a single public api for resolving a cloud id to a user and remote and back
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php')
-rw-r--r--apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php13
1 files changed, 10 insertions, 3 deletions
diff --git a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
index 3c399268124..dd2e88d2dae 100644
--- a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
+++ b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php
@@ -35,6 +35,7 @@ use OCA\Files_Sharing\External\Manager;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
+use OCP\Federation\ICloudIdManager;
use OCP\Files\StorageInvalidException;
use OCP\Http\Client\IClientService;
use OCP\IL10N;
@@ -74,6 +75,9 @@ class MountPublicLinkController extends Controller {
/** @var IClientService */
private $clientService;
+ /** @var ICloudIdManager */
+ private $cloudIdManager;
+
/**
* MountPublicLinkController constructor.
*
@@ -86,6 +90,7 @@ class MountPublicLinkController extends Controller {
* @param IL10N $l
* @param IUserSession $userSession
* @param IClientService $clientService
+ * @param ICloudIdManager $cloudIdManager
*/
public function __construct($appName,
IRequest $request,
@@ -95,7 +100,8 @@ class MountPublicLinkController extends Controller {
ISession $session,
IL10N $l,
IUserSession $userSession,
- IClientService $clientService
+ IClientService $clientService,
+ ICloudIdManager $cloudIdManager
) {
parent::__construct($appName, $request);
@@ -106,6 +112,7 @@ class MountPublicLinkController extends Controller {
$this->l = $l;
$this->userSession = $userSession;
$this->clientService = $clientService;
+ $this->cloudIdManager = $cloudIdManager;
}
/**
@@ -177,7 +184,7 @@ class MountPublicLinkController extends Controller {
return new JSONResponse(['message' => $this->l->t('Server to server sharing is not enabled on this server')], Http::STATUS_BAD_REQUEST);
}
- $shareWith = $this->userSession->getUser()->getUID() . '@' . $this->addressHandler->generateRemoteURL();
+ $cloudId = $this->cloudIdManager->getCloudId($this->userSession->getUser()->getUID(), $this->addressHandler->generateRemoteURL());
$httpClient = $this->clientService->newClient();
@@ -187,7 +194,7 @@ class MountPublicLinkController extends Controller {
'body' =>
[
'token' => $token,
- 'shareWith' => rtrim($shareWith, '/'),
+ 'shareWith' => rtrim($cloudId->getId(), '/'),
'password' => $password
],
'connect_timeout' => 10,