From 9e8354e0ac35090995a0451ccd1166f178815ea1 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Mon, 31 Jul 2023 18:40:13 -0700 Subject: [PATCH] fix: exit on reminder not found Signed-off-by: Christopher Ng --- apps/files_reminders/lib/Notification/Notifier.php | 8 +++++++- apps/files_reminders/lib/Service/ReminderService.php | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) 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); -- 2.39.5