summaryrefslogtreecommitdiffstats
path: root/apps/files_reminders
diff options
context:
space:
mode:
authorPytal <24800714+Pytal@users.noreply.github.com>2023-08-15 08:40:46 -0700
committerGitHub <noreply@github.com>2023-08-15 08:40:46 -0700
commit3c13efdaf20e233ead133690e3072085f7cffc84 (patch)
treebca2423297367b37b441f9e7c28cb7de618861cc /apps/files_reminders
parent892f77033083db46bf211c49e6f3cb49e5257e35 (diff)
parentbe6c4c4058056338a50c2c63f6b1f0bddad3b701 (diff)
downloadnextcloud-server-3c13efdaf20e233ead133690e3072085f7cffc84.tar.gz
nextcloud-server-3c13efdaf20e233ead133690e3072085f7cffc84.zip
Merge pull request #39876 from nextcloud/fix/files-reminders
Diffstat (limited to 'apps/files_reminders')
-rw-r--r--apps/files_reminders/lib/Command/ListCommand.php9
-rw-r--r--apps/files_reminders/lib/Controller/ApiController.php4
-rw-r--r--apps/files_reminders/lib/Db/ReminderMapper.php9
-rw-r--r--apps/files_reminders/lib/Listener/NodeDeletedListener.php6
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);
}
}