From: Christopher Ng Date: Tue, 1 Aug 2023 01:40:13 +0000 (-0700) Subject: fix: exit on reminder not found X-Git-Tag: v28.0.0beta1~601^2~10 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9e8354e0ac35090995a0451ccd1166f178815ea1;p=nextcloud-server.git fix: exit on reminder not found Signed-off-by: Christopher Ng --- 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);