summaryrefslogtreecommitdiffstats
path: root/apps/federatedfilesharing/lib/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'apps/federatedfilesharing/lib/Controller')
-rw-r--r--apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php13
-rw-r--r--apps/federatedfilesharing/lib/Controller/RequestHandlerController.php13
2 files changed, 20 insertions, 6 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,
diff --git a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
index 750415077a8..a5e75e145c8 100644
--- a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
+++ b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
@@ -38,6 +38,7 @@ use OCP\AppFramework\OCS\OCSForbiddenException;
use OCP\AppFramework\OCS\OCSNotFoundException;
use OCP\AppFramework\OCSController;
use OCP\Constants;
+use OCP\Federation\ICloudIdManager;
use OCP\Files\NotFoundException;
use OCP\IDBConnection;
use OCP\IRequest;
@@ -68,6 +69,9 @@ class RequestHandlerController extends OCSController {
/** @var string */
private $shareTable = 'share';
+ /** @var ICloudIdManager */
+ private $cloudIdManager;
+
/**
* Server2Server constructor.
*
@@ -79,6 +83,7 @@ class RequestHandlerController extends OCSController {
* @param Notifications $notifications
* @param AddressHandler $addressHandler
* @param IUserManager $userManager
+ * @param ICloudIdManager $cloudIdManager
*/
public function __construct($appName,
IRequest $request,
@@ -87,7 +92,8 @@ class RequestHandlerController extends OCSController {
Share\IManager $shareManager,
Notifications $notifications,
AddressHandler $addressHandler,
- IUserManager $userManager
+ IUserManager $userManager,
+ ICloudIdManager $cloudIdManager
) {
parent::__construct($appName, $request);
@@ -97,6 +103,7 @@ class RequestHandlerController extends OCSController {
$this->notifications = $notifications;
$this->addressHandler = $addressHandler;
$this->userManager = $userManager;
+ $this->cloudIdManager = $cloudIdManager;
}
/**
@@ -164,7 +171,7 @@ class RequestHandlerController extends OCSController {
$shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external');
if ($ownerFederatedId === null) {
- $ownerFederatedId = $owner . '@' . $this->cleanupRemote($remote);
+ $ownerFederatedId = $this->cloudIdManager->getCloudId($owner, $this->cleanupRemote($remote))->getId();
}
// if the owner of the share and the initiator are the same user
// we also complete the federated share ID for the initiator
@@ -424,7 +431,7 @@ class RequestHandlerController extends OCSController {
$remote = $this->cleanupRemote($share['remote']);
- $owner = $share['owner'] . '@' . $remote;
+ $owner = $this->cloudIdManager->getCloudId($share['owner'], $remote);
$mountpoint = $share['mountpoint'];
$user = $share['user'];