diff options
author | Joas Schilling <coding@schilljs.com> | 2018-10-24 14:25:35 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-03-01 20:56:16 +0100 |
commit | 702dcfb72848b36921a310188aa019d810668ebc (patch) | |
tree | 449f8965032eda43db1a029f4f13bebedd83029a /core/Controller | |
parent | 5dfc56e925309d637be6f5a69cc16d0baaf20d03 (diff) | |
download | nextcloud-server-702dcfb72848b36921a310188aa019d810668ebc.tar.gz nextcloud-server-702dcfb72848b36921a310188aa019d810668ebc.zip |
Make names mandatory
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core/Controller')
-rw-r--r-- | core/Controller/CollaborationResourcesController.php | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/core/Controller/CollaborationResourcesController.php b/core/Controller/CollaborationResourcesController.php index 453a6405e56..e9fc7b1ac70 100644 --- a/core/Controller/CollaborationResourcesController.php +++ b/core/Controller/CollaborationResourcesController.php @@ -163,27 +163,27 @@ class CollaborationResourcesController extends OCSController { /** * @NoAdminRequired * - * @param string $baseResourceType - * @param string $baseResourceId * @param string $resourceType * @param string $resourceId + * @param string $name * @return DataResponse */ - public function createCollectionOnResource(string $baseResourceType, string $baseResourceId, string $resourceType, string $resourceId): DataResponse { + public function createCollectionOnResource(string $resourceType, string $resourceId, string $name): DataResponse { + if (!isset($name[0]) || isset($name[64])) { + return new DataResponse([], Http::STATUS_BAD_REQUEST); + } + try { - $baseResource = $this->manager->getResource($baseResourceType, $baseResourceId); $resource = $this->manager->getResource($resourceType, $resourceId); } catch (CollectionException $e) { return new DataResponse([], Http::STATUS_NOT_FOUND); } - if (!$baseResource->canAccess($this->userSession->getUser()) || - !$resource->canAccess($this->userSession->getUser())) { + if (!$resource->canAccess($this->userSession->getUser())) { return new DataResponse([], Http::STATUS_NOT_FOUND); } - $collection = $this->manager->newCollection(); - $collection->addResource($baseResource); + $collection = $this->manager->newCollection($name); $collection->addResource($resource); return new DataResponse($this->prepareCollection($collection)); @@ -192,6 +192,7 @@ class CollaborationResourcesController extends OCSController { protected function prepareCollection(ICollection $collection): array { return [ 'id' => $collection->getId(), + 'name' => $collection->getName(), 'resources' => array_map([$this, 'prepareResources'], $collection->getResources()), ]; } |