diff options
author | Christopher Ng <chrng8@gmail.com> | 2023-07-31 12:10:50 -0700 |
---|---|---|
committer | Christopher Ng <chrng8@gmail.com> | 2023-08-08 16:29:12 -0700 |
commit | ee7aff33429b1023553b61820ed515ab60992aa5 (patch) | |
tree | 39b01a4cebef42a0be267d2401ebe449465c5052 | |
parent | 67abe990479c6d9dc650edaa27a99cbcca088e06 (diff) | |
download | nextcloud-server-ee7aff33429b1023553b61820ed515ab60992aa5.tar.gz nextcloud-server-ee7aff33429b1023553b61820ed515ab60992aa5.zip |
fix: return ocs data
Signed-off-by: Christopher Ng <chrng8@gmail.com>
(cherry picked from commit 3ade06cd9c1ddcf8a5d0a140d40b7fab0ecfccd3)
-rw-r--r-- | apps/files_reminders/lib/Controller/ApiController.php | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/apps/files_reminders/lib/Controller/ApiController.php b/apps/files_reminders/lib/Controller/ApiController.php index 7f6e24debe2..af5cc1b32a7 100644 --- a/apps/files_reminders/lib/Controller/ApiController.php +++ b/apps/files_reminders/lib/Controller/ApiController.php @@ -34,7 +34,7 @@ use OCA\FilesReminders\Exception\NodeNotFoundException; use OCA\FilesReminders\Service\ReminderService; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Http; -use OCP\AppFramework\Http\JSONResponse; +use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCSController; use OCP\IRequest; use OCP\IUserSession; @@ -55,10 +55,10 @@ class ApiController extends OCSController { /** * Get a reminder */ - public function get(int $fileId): JSONResponse { + public function get(int $fileId): DataResponse { $user = $this->userSession->getUser(); if ($user === null) { - return new JSONResponse([], Http::STATUS_UNAUTHORIZED); + return new DataResponse([], Http::STATUS_UNAUTHORIZED); } try { @@ -66,15 +66,15 @@ class ApiController extends OCSController { $reminderData = [ 'dueDate' => $reminder->getDueDate()->format(DateTimeInterface::ATOM), // ISO 8601 ]; - return new JSONResponse($reminderData, Http::STATUS_OK); + return new DataResponse($reminderData, Http::STATUS_OK); } catch (DoesNotExistException $e) { $reminderData = [ 'dueDate' => null, ]; - return new JSONResponse($reminderData, Http::STATUS_OK); + return new DataResponse($reminderData, Http::STATUS_OK); } catch (Throwable $th) { $this->logger->error($th->getMessage(), ['exception' => $th]); - return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR); + return new DataResponse([], Http::STATUS_INTERNAL_SERVER_ERROR); } } @@ -83,50 +83,50 @@ class ApiController extends OCSController { * * @param string $dueDate ISO 8601 formatted date time string */ - public function set(int $fileId, string $dueDate): JSONResponse { + public function set(int $fileId, string $dueDate): DataResponse { try { $dueDate = (new DateTime($dueDate))->setTimezone(new DateTimeZone('UTC')); } catch (Exception $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); - return new JSONResponse([], Http::STATUS_BAD_REQUEST); + return new DataResponse([], Http::STATUS_BAD_REQUEST); } $user = $this->userSession->getUser(); if ($user === null) { - return new JSONResponse([], Http::STATUS_UNAUTHORIZED); + return new DataResponse([], Http::STATUS_UNAUTHORIZED); } try { $created = $this->reminderService->createOrUpdate($user, $fileId, $dueDate); if ($created) { - return new JSONResponse([], Http::STATUS_CREATED); + return new DataResponse([], Http::STATUS_CREATED); } - return new JSONResponse([], Http::STATUS_OK); + return new DataResponse([], Http::STATUS_OK); } catch (NodeNotFoundException $e) { - return new JSONResponse([], Http::STATUS_NOT_FOUND); + return new DataResponse([], Http::STATUS_NOT_FOUND); } catch (Throwable $th) { $this->logger->error($th->getMessage(), ['exception' => $th]); - return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR); + return new DataResponse([], Http::STATUS_INTERNAL_SERVER_ERROR); } } /** * Remove a reminder */ - public function remove(int $fileId): JSONResponse { + public function remove(int $fileId): DataResponse { $user = $this->userSession->getUser(); if ($user === null) { - return new JSONResponse([], Http::STATUS_UNAUTHORIZED); + return new DataResponse([], Http::STATUS_UNAUTHORIZED); } try { $this->reminderService->remove($user, $fileId); - return new JSONResponse([], Http::STATUS_OK); + return new DataResponse([], Http::STATUS_OK); } catch (DoesNotExistException $e) { - return new JSONResponse([], Http::STATUS_NOT_FOUND); + return new DataResponse([], Http::STATUS_NOT_FOUND); } catch (Throwable $th) { $this->logger->error($th->getMessage(), ['exception' => $th]); - return new JSONResponse([], Http::STATUS_INTERNAL_SERVER_ERROR); + return new DataResponse([], Http::STATUS_INTERNAL_SERVER_ERROR); } } } |