Skip to content

Commit

Permalink
fix(notifications): Notifier::prepare() threw \InvalidArgumentExcepti…
Browse files Browse the repository at this point in the history
…on which is deprecated

Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Dec 20, 2024
1 parent 2a10617 commit ca9601c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use OCP\Notification\IAction;
use OCP\Notification\INotification;
use OCP\Notification\INotifier;
use OCP\Notification\UnknownNotificationException;

class Notifier implements INotifier {
public const SUBJECT = 'announced';
Expand Down Expand Up @@ -64,12 +65,12 @@ 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
*/
public function prepare(INotification $notification, string $languageCode): INotification {
if ($notification->getApp() !== $this->appName) {
// Not my app => throw
throw new \InvalidArgumentException();
throw new UnknownNotificationException();
}

// Read the language from the notification
Expand Down Expand Up @@ -108,7 +109,7 @@ public function prepare(INotification $notification, string $languageCode): INot

default:
// Unknown subject => Unknown notification => throw
throw new \InvalidArgumentException();
throw new UnknownNotificationException();
}
}
}

0 comments on commit ca9601c

Please sign in to comment.