From cbefa3eb9120626377c3e972bb052ed2a2e4f28d Mon Sep 17 00:00:00 2001 From: Oleksander Piskun Date: Fri, 11 Sep 2026 14:07:15 +0000 Subject: [PATCH] fix: throw UnknownNotificationException for unknown notifications Notifier::prepare() threw \InvalidArgumentException for a notification it does not know, both for another app's notification and for an unknown subject of its own. Since Nextcloud 30 the server logs a deprecation warning for every such call, so an instance with this app enabled wrote one line per notification any other app sent. UnknownNotificationException extends \InvalidArgumentException and has existed since Nextcloud 30, below the app's min-version of 33, so callers catching the old type are unaffected. Signed-off-by: Oleksander Piskun --- CHANGELOG.md | 1 + lib/Notification/Notifier.php | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d69abc5..a772347 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Stop a file import from blocking forever when a download stalls - Stop logging download URLs, they contain a short lived access token - Retry a failed file download once with a freshly fetched download URL, the one from the folder listing may have expired during a long import +- Stop logging a deprecation warning every time another app sends a notification ## [3.5.2] - 2026-07-28 diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index 41de0e5..112fcf6 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -7,7 +7,6 @@ namespace OCA\Onedrive\Notification; -use InvalidArgumentException; use OCA\Onedrive\AppInfo\Application; use OCP\IURLGenerator; use OCP\IUserManager; @@ -15,6 +14,7 @@ use OCP\Notification\IManager as INotificationManager; use OCP\Notification\INotification; use OCP\Notification\INotifier; +use OCP\Notification\UnknownNotificationException; class Notifier implements INotifier { @@ -69,13 +69,13 @@ public function getName(): string { * @param INotification $notification * @param string $languageCode The code of the language that should be used to prepare the notification * @return INotification - * @throws InvalidArgumentException When the notification was not prepared by a notifier + * @throws UnknownNotificationException When the notification was not prepared by a notifier * @since 9.0.0 */ public function prepare(INotification $notification, string $languageCode): INotification { if ($notification->getApp() !== 'integration_onedrive') { // Not my app => throw - throw new InvalidArgumentException(); + throw new UnknownNotificationException(); } $l = $this->factory->get('integration_onedrive', $languageCode); @@ -94,7 +94,7 @@ public function prepare(INotification $notification, string $languageCode): INot return $notification; default: // Unknown subject => Unknown notification => throw - throw new InvalidArgumentException(); + throw new UnknownNotificationException(); } } }