diff options
author | Christopher Ng <chrng8@gmail.com> | 2023-08-09 10:20:32 -0700 |
---|---|---|
committer | Andy Scherzinger <info@andy-scherzinger.de> | 2023-08-10 12:28:19 +0200 |
commit | 0c0ed382f84ad1b5f1ca1ee6165dfa79c6118f0a (patch) | |
tree | 424a9c3a150650eefa74c3c665b7cf1a33eaf02d /apps/files_reminders/lib | |
parent | 15ade72d18359408da14942d729583ffc2f72b4f (diff) | |
download | nextcloud-server-0c0ed382f84ad1b5f1ca1ee6165dfa79c6118f0a.tar.gz nextcloud-server-0c0ed382f84ad1b5f1ca1ee6165dfa79c6118f0a.zip |
enh: pass params in subject
Signed-off-by: Christopher Ng <chrng8@gmail.com>
(cherry picked from commit 86db2d7f15f8507e9c563507491b7dba3c63e932)
Diffstat (limited to 'apps/files_reminders/lib')
-rw-r--r-- | apps/files_reminders/lib/Notification/Notifier.php | 21 | ||||
-rw-r--r-- | apps/files_reminders/lib/Service/ReminderService.php | 4 |
2 files changed, 11 insertions, 14 deletions
diff --git a/apps/files_reminders/lib/Notification/Notifier.php b/apps/files_reminders/lib/Notification/Notifier.php index c528aa521b1..ce46aafb86c 100644 --- a/apps/files_reminders/lib/Notification/Notifier.php +++ b/apps/files_reminders/lib/Notification/Notifier.php @@ -28,10 +28,8 @@ namespace OCA\FilesReminders\Notification; 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\Files\IRootFolder; use OCP\IURLGenerator; use OCP\L10N\IFactory; use OCP\Notification\AlreadyProcessedException; @@ -43,7 +41,7 @@ class Notifier implements INotifier { public function __construct( protected IFactory $l10nFactory, protected IURLGenerator $urlGenerator, - protected ReminderService $reminderService, + protected IRootFolder $root, ) {} public function getID(): string { @@ -67,18 +65,15 @@ class Notifier implements INotifier { switch ($notification->getSubject()) { case 'reminder-due': - $reminderId = (int)$notification->getObjectId(); - try { - $reminder = $this->reminderService->get($reminderId); - } catch (DoesNotExistException $e) { - throw new AlreadyProcessedException(); - } + $params = $notification->getSubjectParameters(); + $fileId = $params['fileId']; - try { - $node = $reminder->getNode(); - } catch (NodeNotFoundException $e) { + $nodes = $this->root->getUserFolder($notification->getUser())->getById($fileId); + if (empty($nodes)) { throw new InvalidArgumentException(); } + $node = reset($nodes); + $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 010f458e872..4bfa943cb04 100644 --- a/apps/files_reminders/lib/Service/ReminderService.php +++ b/apps/files_reminders/lib/Service/ReminderService.php @@ -155,7 +155,9 @@ class ReminderService { ->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('files', 'folder.svg'))) ->setUser($user->getUID()) ->setObject('reminder', (string)$reminder->getId()) - ->setSubject('reminder-due') + ->setSubject('reminder-due', [ + 'fileId' => $reminder->getFileId(), + ]) ->setDateTime($reminder->getDueDate()); try { |