From 94f22e7807dd0f4c2c382cde82f98157b6f75995 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 3 Aug 2023 11:25:26 +0200 Subject: [PATCH] fix(notifications): Remove share notification when the node is deleted Signed-off-by: Joas Schilling --- apps/files_sharing/lib/Notification/Notifier.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/files_sharing/lib/Notification/Notifier.php b/apps/files_sharing/lib/Notification/Notifier.php index 455d0fd66fcf3..d339c484dd789 100644 --- a/apps/files_sharing/lib/Notification/Notifier.php +++ b/apps/files_sharing/lib/Notification/Notifier.php @@ -29,6 +29,7 @@ namespace OCA\Files_Sharing\Notification; use OCP\Files\IRootFolder; +use OCP\Files\NotFoundException; use OCP\IGroupManager; use OCP\IL10N; use OCP\IURLGenerator; @@ -117,6 +118,13 @@ public function prepare(INotification $notification, string $languageCode): INot throw new AlreadyProcessedException(); } + try { + $share->getNode(); + } catch (NotFoundException $e) { + // Node is already deleted, so discard the notification + throw new AlreadyProcessedException(); + } + if ($notification->getSubject() === 'expiresTomorrow') { $notification = $this->parseShareExpiration($share, $notification, $l); } else {