diff options
author | Christopher Ng <chrng8@gmail.com> | 2023-07-31 12:10:50 -0700 |
---|---|---|
committer | Christopher Ng <chrng8@gmail.com> | 2023-08-03 15:30:11 -0700 |
commit | 777a791e72b9e8982228ff5a39cd61b7f051d8e4 (patch) | |
tree | 72e01f51b7d1922793f0284ada5e804e66c56ef5 /apps/files_reminders/lib/Controller | |
parent | 05e454ee614705ec0c8be264c456b7c647be7c03 (diff) | |
download | nextcloud-server-777a791e72b9e8982228ff5a39cd61b7f051d8e4.tar.gz nextcloud-server-777a791e72b9e8982228ff5a39cd61b7f051d8e4.zip |
feat(files_reminders): add remove endpoint
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps/files_reminders/lib/Controller')
-rw-r--r-- | apps/files_reminders/lib/Controller/ApiController.php | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/apps/files_reminders/lib/Controller/ApiController.php b/apps/files_reminders/lib/Controller/ApiController.php index de69997f616..ddc34b16c6b 100644 --- a/apps/files_reminders/lib/Controller/ApiController.php +++ b/apps/files_reminders/lib/Controller/ApiController.php @@ -67,11 +67,7 @@ class ApiController extends OCSController { ]; return new JSONResponse($reminderData, Http::STATUS_OK); } catch (DoesNotExistException $e) { - // Return null when no reminder is found - $reminderData = [ - 'dueDate' => null, - ]; - return new JSONResponse($reminderData, Http::STATUS_OK); + return new JSONResponse([], Http::STATUS_NOT_FOUND); } catch (Throwable $th) { $this->logger->error($th->getMessage(), ['exception' => $th]); return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR); @@ -104,4 +100,24 @@ class ApiController extends OCSController { return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR); } } + + /** + * Remove a reminder + */ + public function remove(int $fileId): JSONResponse { + $user = $this->userSession->getUser(); + if ($user === null) { + return new JSONResponse([], Http::STATUS_UNAUTHORIZED); + } + + try { + $this->reminderService->remove($user, $fileId); + return new JSONResponse([], Http::STATUS_OK); + } catch (DoesNotExistException $e) { + return new JSONResponse([], Http::STATUS_NOT_FOUND); + } catch (Throwable $th) { + $this->logger->error($th->getMessage(), ['exception' => $th]); + return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR); + } + } } |