Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
43ac71a
feat: init files_reminders migration
Pytal Jul 31, 2023
29a78fe
feat(files_reminders): add Application
Pytal Jul 31, 2023
6da4542
feat(files_reminders): add info xml
Pytal Jul 31, 2023
b195fe7
feat(files_reminders): add background jobs
Pytal Jul 31, 2023
782a462
feat(files_reminders): add service and notifier
Pytal Jul 31, 2023
5aca833
feat(files_reminders): add list command
Pytal Jul 31, 2023
cbbd0c6
enh: use datetime
Pytal Jul 31, 2023
5e8668b
enh: add created at
Pytal Jul 31, 2023
f5036b5
enh: implement JsonSerializable
Pytal Jul 31, 2023
143346b
feat(files_reminders): add api controller
Pytal Jul 31, 2023
ca003e2
fix: add composer autoload
Pytal Jul 31, 2023
bb4134a
enh: add to shipped
Pytal Jul 31, 2023
c0f327d
enh: rename to due date
Pytal Jul 31, 2023
3f668f3
fix: catch Throwable
Pytal Jul 31, 2023
e99f1b0
enh: add updated at
Pytal Jul 31, 2023
f4c7759
feat(files_reminders): create or update
Pytal Jul 31, 2023
fb71f8c
fix: update find due query
Pytal Jul 31, 2023
ab357bf
feat(files_reminders): add remove endpoint
Pytal Jul 31, 2023
332fd3d
fix: create only if file exists
Pytal Jul 31, 2023
8a410f1
enh: return created status code
Pytal Jul 31, 2023
b77a375
enh: comment interval
Pytal Jul 31, 2023
8f54e2c
enh: serialize path
Pytal Jul 31, 2023
67abe99
enh: does not exist return null
Pytal Jul 31, 2023
ee7aff3
fix: return ocs data
Pytal Jul 31, 2023
67df581
fix: remove throwable handling
Pytal Jul 31, 2023
1c6114b
fix: construct background jobs
Pytal Jul 31, 2023
e12ae21
enh: handle node deleted
Pytal Aug 1, 2023
6fc3530
fix: exit on reminder not found
Pytal Aug 1, 2023
fa7985d
fix: catch NodeNotFoundException in notifier
Pytal Aug 1, 2023
3b81da9
enh: highlight filename
Pytal Aug 1, 2023
05436ac
fix: remove unnecessary parsed subject
Pytal Aug 1, 2023
cdaee2b
fix: return null if table exists
Pytal Aug 1, 2023
0ffb367
enh: add codeowner
Pytal Aug 1, 2023
a377862
enh: add json output to command
Pytal Aug 1, 2023
33f30f5
fix: ignore non-existing
Pytal Aug 1, 2023
2e8906f
fix(ci): add to enabled apps
Pytal Aug 1, 2023
dfba8f4
fix: set endpoint description
Pytal Aug 2, 2023
d3991ee
enh: handle user deleted
Pytal Aug 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: return ocs data
Signed-off-by: Christopher Ng <[email protected]>
(cherry picked from commit 3ade06c)
  • Loading branch information
Pytal committed Aug 8, 2023
commit ee7aff33429b1023553b61820ed515ab60992aa5
36 changes: 18 additions & 18 deletions apps/files_reminders/lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
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;
Expand All @@ -55,26 +55,26 @@ public function __construct(
/**
* 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 {
$reminder = $this->reminderService->getDueForUser($user, $fileId);
$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);
}
}

Expand All @@ -83,50 +83,50 @@ public function get(int $fileId): JSONResponse {
*
* @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);
}
}
}