diff options
author | Pytal <24800714+Pytal@users.noreply.github.com> | 2023-08-15 09:55:04 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-15 09:55:04 -0700 |
commit | 493d164dfb4322b7f419fb9c66f21ebc9e369a62 (patch) | |
tree | 830b2c70cb6d716054e7bace2e421d1551cd9836 | |
parent | c535210496967c119bad008cd1b9cec21ae766b1 (diff) | |
parent | 95688ea41291ab9e2dbb80bacea20be0c16d0774 (diff) | |
download | nextcloud-server-493d164dfb4322b7f419fb9c66f21ebc9e369a62.tar.gz nextcloud-server-493d164dfb4322b7f419fb9c66f21ebc9e369a62.zip |
Merge pull request #39887 from nextcloud/backport/39876/stable27
4 files changed, 17 insertions, 11 deletions
diff --git a/apps/files_reminders/lib/Command/ListCommand.php b/apps/files_reminders/lib/Command/ListCommand.php index 3f3ce13b857..f9113e15605 100644 --- a/apps/files_reminders/lib/Command/ListCommand.php +++ b/apps/files_reminders/lib/Command/ListCommand.php @@ -77,10 +77,6 @@ class ListCommand extends Base { } $reminders = $this->reminderService->getAll($user ?? null); - if (empty($reminders)) { - $io->text('No reminders'); - return 0; - } $outputOption = $input->getOption('output'); switch ($outputOption) { @@ -97,6 +93,11 @@ class ListCommand extends Base { ); return 0; default: + if (empty($reminders)) { + $io->text('No reminders'); + return 0; + } + $io->table( ['User Id', 'File Id', 'Path', 'Due Date', 'Updated At', 'Created At', 'Notified'], array_map( diff --git a/apps/files_reminders/lib/Controller/ApiController.php b/apps/files_reminders/lib/Controller/ApiController.php index 873088177c1..ed23ee032ba 100644 --- a/apps/files_reminders/lib/Controller/ApiController.php +++ b/apps/files_reminders/lib/Controller/ApiController.php @@ -34,6 +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\Attribute\NoAdminRequired; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCSController; use OCP\IRequest; @@ -54,6 +55,7 @@ class ApiController extends OCSController { /** * Get a reminder */ + #[NoAdminRequired] public function get(int $fileId): DataResponse { $user = $this->userSession->getUser(); if ($user === null) { @@ -79,6 +81,7 @@ class ApiController extends OCSController { * * @param string $dueDate ISO 8601 formatted date time string */ + #[NoAdminRequired] public function set(int $fileId, string $dueDate): DataResponse { try { $dueDate = (new DateTime($dueDate))->setTimezone(new DateTimeZone('UTC')); @@ -106,6 +109,7 @@ class ApiController extends OCSController { /** * Remove a reminder */ + #[NoAdminRequired] public function remove(int $fileId): DataResponse { $user = $this->userSession->getUser(); if ($user === null) { diff --git a/apps/files_reminders/lib/Db/ReminderMapper.php b/apps/files_reminders/lib/Db/ReminderMapper.php index 1a8f05a3db9..3f7fc04b2f0 100644 --- a/apps/files_reminders/lib/Db/ReminderMapper.php +++ b/apps/files_reminders/lib/Db/ReminderMapper.php @@ -31,6 +31,7 @@ use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\QBMapper; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Files\Node; +use OCP\Files\NotFoundException; use OCP\IDBConnection; use OCP\IUser; @@ -111,11 +112,17 @@ class ReminderMapper extends QBMapper { * @return Reminder[] */ public function findAllForNode(Node $node) { + try { + $nodeId = $node->getId(); + } catch (NotFoundException $e) { + return []; + } + $qb = $this->db->getQueryBuilder(); $qb->select('id', 'user_id', 'file_id', 'due_date', 'updated_at', 'created_at', 'notified') ->from($this->getTableName()) - ->where($qb->expr()->eq('file_id', $qb->createNamedParameter($node->getId(), IQueryBuilder::PARAM_INT))) + ->where($qb->expr()->eq('file_id', $qb->createNamedParameter($nodeId, IQueryBuilder::PARAM_INT))) ->orderBy('due_date', 'ASC'); return $this->findEntities($qb); diff --git a/apps/files_reminders/lib/Listener/NodeDeletedListener.php b/apps/files_reminders/lib/Listener/NodeDeletedListener.php index 460ddfd4abe..88aed08bba8 100644 --- a/apps/files_reminders/lib/Listener/NodeDeletedListener.php +++ b/apps/files_reminders/lib/Listener/NodeDeletedListener.php @@ -26,8 +26,6 @@ declare(strict_types=1); namespace OCA\FilesReminders\Listener; -use OC\Files\Node\NonExistingFile; -use OC\Files\Node\NonExistingFolder; use OCA\FilesReminders\Service\ReminderService; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; @@ -44,10 +42,6 @@ class NodeDeletedListener implements IEventListener { } $node = $event->getNode(); - if ($node instanceof NonExistingFile || $node instanceof NonExistingFolder) { - return; - } - $this->reminderService->removeAllForNode($node); } } |