diff options
author | Sean Molenaar <sean@seanmolenaar.eu> | 2020-10-04 20:45:33 +0200 |
---|---|---|
committer | Benjamin Brahmer <info@b-brahmer.de> | 2020-11-03 19:58:37 +0100 |
commit | 10e8c28feaf6d858948285a291231f651ef74728 (patch) | |
tree | 5c48216dc1ce6a6dd8f292d489bb4a7d03cb5595 /lib/Controller/FolderApiController.php | |
parent | 361cfa55b7302b29e158647060085550b9a3dfe1 (diff) |
Add migration with foreign keys
Closes #829
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'lib/Controller/FolderApiController.php')
-rw-r--r-- | lib/Controller/FolderApiController.php | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/Controller/FolderApiController.php b/lib/Controller/FolderApiController.php index 1f79d7cf9..691c67139 100644 --- a/lib/Controller/FolderApiController.php +++ b/lib/Controller/FolderApiController.php @@ -90,12 +90,16 @@ class FolderApiController extends ApiController * @NoCSRFRequired * @CORS * - * @param int $folderId + * @param int|null $folderId * * @return array|JSONResponse */ - public function delete(int $folderId) + public function delete(?int $folderId) { + if (empty($folderId)) { + return new JSONResponse([], Http::STATUS_BAD_REQUEST); + } + try { $this->folderService->delete($folderId, $this->getUserId()); } catch (ServiceNotFoundException $ex) { @@ -111,13 +115,17 @@ class FolderApiController extends ApiController * @NoCSRFRequired * @CORS * - * @param int $folderId - * @param string $name + * @param int|null $folderId + * @param string $name * * @return array|JSONResponse */ - public function update(int $folderId, string $name) + public function update(?int $folderId, string $name) { + if (empty($folderId)) { + return new JSONResponse([], Http::STATUS_BAD_REQUEST); + } + try { $this->folderService->rename($folderId, $name, $this->getUserId()); } catch (ServiceValidationException $ex) { @@ -137,11 +145,14 @@ class FolderApiController extends ApiController * @NoCSRFRequired * @CORS * - * @param int $folderId - * @param int $newestItemId + * @param int|null $folderId + * @param int $newestItemId */ - public function read(int $folderId, int $newestItemId): void + public function read(?int $folderId, int $newestItemId): void { + if ($folderId === 0) { + $folderId = null; + } $this->itemService->readFolder($folderId, $newestItemId, $this->getUserId()); } } |