aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2023-07-31 18:40:13 -0700
committerChristopher Ng <chrng8@gmail.com>2023-08-03 15:30:11 -0700
commit9e8354e0ac35090995a0451ccd1166f178815ea1 (patch)
treedc707b921fa6edbfe9bc3882fd786dd36c497c22
parentf865c3ad21e03483a6f16b90a4383faef0356499 (diff)
downloadnextcloud-server-9e8354e0ac35090995a0451ccd1166f178815ea1.tar.gz
nextcloud-server-9e8354e0ac35090995a0451ccd1166f178815ea1.zip
fix: exit on reminder not found
Signed-off-by: Christopher Ng <chrng8@gmail.com>
-rw-r--r--apps/files_reminders/lib/Notification/Notifier.php8
-rw-r--r--apps/files_reminders/lib/Service/ReminderService.php3
2 files changed, 10 insertions, 1 deletions
diff --git a/apps/files_reminders/lib/Notification/Notifier.php b/apps/files_reminders/lib/Notification/Notifier.php
index fb1d3264dbd..c7384b43224 100644
--- a/apps/files_reminders/lib/Notification/Notifier.php
+++ b/apps/files_reminders/lib/Notification/Notifier.php
@@ -30,6 +30,7 @@ use InvalidArgumentException;
use OCA\FilesReminders\AppInfo\Application;
use OCA\FilesReminders\Exception\NodeNotFoundException;
use OCA\FilesReminders\Service\ReminderService;
+use OCP\AppFramework\Db\DoesNotExistException;
use OCP\Files\FileInfo;
use OCP\IURLGenerator;
use OCP\L10N\IFactory;
@@ -66,8 +67,13 @@ class Notifier implements INotifier {
switch ($notification->getSubject()) {
case 'reminder-due':
$reminderId = (int)$notification->getObjectId();
- $node = $this->reminderService->get($reminderId)->getNode();
+ try {
+ $reminder = $this->reminderService->get($reminderId);
+ } catch (DoesNotExistException $e) {
+ throw new InvalidArgumentException();
+ }
+ $node = $reminder->getNode();
$path = rtrim($node->getPath(), '/');
if (strpos($path, '/' . $notification->getUser() . '/files/') === 0) {
// Remove /user/files/...
diff --git a/apps/files_reminders/lib/Service/ReminderService.php b/apps/files_reminders/lib/Service/ReminderService.php
index eec2f1780bd..91652a4e0be 100644
--- a/apps/files_reminders/lib/Service/ReminderService.php
+++ b/apps/files_reminders/lib/Service/ReminderService.php
@@ -54,6 +54,9 @@ class ReminderService {
protected LoggerInterface $logger,
) {}
+ /**
+ * @throws DoesNotExistException
+ */
public function get(int $id): RichReminder {
$reminder = $this->reminderMapper->find($id);
return new RichReminder($reminder, $this->root);