diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2018-05-04 15:25:02 +0200 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2018-07-02 11:29:27 +0200 |
commit | a3948e8a126d6f84629841c8886fe0819ab04ad5 (patch) | |
tree | 55e8458dfc9cf257f3ec6b5a40c9d0ff03e73d67 /apps/cloud_federation_api | |
parent | 6208f250e88a15794ac5b7eeef6d701aa91e131b (diff) | |
download | nextcloud-server-a3948e8a126d6f84629841c8886fe0819ab04ad5.tar.gz nextcloud-server-a3948e8a126d6f84629841c8886fe0819ab04ad5.zip |
use new API to send a federated share if possible
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/cloud_federation_api')
-rw-r--r-- | apps/cloud_federation_api/lib/Controller/RequestHandlerController.php | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php b/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php index d551f464c22..4f16c369a2f 100644 --- a/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php +++ b/apps/cloud_federation_api/lib/Controller/RequestHandlerController.php @@ -32,6 +32,7 @@ use OCP\Federation\Exceptions\ShareNotFoundException; use OCP\Federation\ICloudFederationFactory; use OCP\Federation\ICloudFederationProviderManager; use OCP\Federation\Exceptions\ProviderDoesNotExistsException; +use OCP\Federation\ICloudIdManager; use OCP\ILogger; use OCP\IRequest; use OCP\IURLGenerator; @@ -65,6 +66,9 @@ class RequestHandlerController extends Controller { /** @var ICloudFederationFactory */ private $factory; + /** @var ICloudIdManager */ + private $cloudIdManager; + public function __construct($appName, IRequest $request, ILogger $logger, @@ -72,7 +76,8 @@ class RequestHandlerController extends Controller { IURLGenerator $urlGenerator, ICloudFederationProviderManager $cloudFederationProviderManager, Config $config, - ICloudFederationFactory $factory + ICloudFederationFactory $factory, + ICloudIdManager $cloudIdManager ) { parent::__construct($appName, $request); @@ -82,6 +87,7 @@ class RequestHandlerController extends Controller { $this->cloudFederationProviderManager = $cloudFederationProviderManager; $this->config = $config; $this->factory = $factory; + $this->cloudIdManager = $cloudIdManager; } /** @@ -104,7 +110,7 @@ class RequestHandlerController extends Controller { * @param $resourceType ('file', 'calendar',...) * @return Http\DataResponse|JSONResponse * - * Example: curl -H "Content-Type: application/json" -X POST -d '{"shareWith":"admin1","name":"welcome server2.txt","description":"desc","providerId":"2","owner":"admin2@http://localhost/server2","ownerDisplayName":"admin2 display","shareType":"user","resourceType":"file","protocol":{"name":"webdav","options":{"access_token":"8Lrd1FVEREthux7","permissions":31}}}' http://localhost/server/index.php/ocm/shares + * Example: curl -H "Content-Type: application/json" -X POST -d '{"shareWith":"admin1@serve1","name":"welcome server2.txt","description":"desc","providerId":"2","owner":"admin2@http://localhost/server2","ownerDisplayName":"admin2 display","shareType":"user","resourceType":"file","protocol":{"name":"webdav","options":{"access_token":"8Lrd1FVEREthux7","permissions":31}}}' http://localhost/server/index.php/ocm/shares */ public function addShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $protocol, $shareType, $resourceType) { @@ -133,7 +139,9 @@ class RequestHandlerController extends Controller { ); } - $shareWith = $this->mapUid($shareWith); + $cloudId = $this->cloudIdManager->resolveCloudId($shareWith); + $shareWithLocalId = $cloudId->getUser(); + $shareWith = $this->mapUid($shareWithLocalId); if (!$this->userManager->userExists($shareWith)) { return new JSONResponse( |