]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix: exit on reminder not found
authorChristopher Ng <chrng8@gmail.com>
Tue, 1 Aug 2023 01:40:13 +0000 (18:40 -0700)
committerChristopher Ng <chrng8@gmail.com>
Thu, 3 Aug 2023 22:30:11 +0000 (15:30 -0700)
Signed-off-by: Christopher Ng <chrng8@gmail.com>
apps/files_reminders/lib/Notification/Notifier.php
apps/files_reminders/lib/Service/ReminderService.php

index fb1d3264dbda682aa73105324a5c700ba0925744..c7384b43224ad6519802a1bb3026f044a25981c3 100644 (file)
@@ -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/...
index eec2f1780bd38e0738fa87f3605299bb3e9eb394..91652a4e0be5dadc1943ec95e85c5ed1bd95f6a1 100644 (file)
@@ -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);