diff options
Diffstat (limited to 'apps/comments/lib/Notification/Notifier.php')
-rw-r--r-- | apps/comments/lib/Notification/Notifier.php | 38 |
1 files changed, 11 insertions, 27 deletions
diff --git a/apps/comments/lib/Notification/Notifier.php b/apps/comments/lib/Notification/Notifier.php index 9501c8b954c..62562bf42aa 100644 --- a/apps/comments/lib/Notification/Notifier.php +++ b/apps/comments/lib/Notification/Notifier.php @@ -1,26 +1,9 @@ <?php + /** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Joas Schilling <coding@schilljs.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ namespace OCA\Comments\Notification; @@ -34,6 +17,7 @@ use OCP\L10N\IFactory; use OCP\Notification\AlreadyProcessedException; use OCP\Notification\INotification; use OCP\Notification\INotifier; +use OCP\Notification\UnknownNotificationException; class Notifier implements INotifier { public function __construct( @@ -41,7 +25,7 @@ class Notifier implements INotifier { protected IRootFolder $rootFolder, protected ICommentsManager $commentsManager, protected IURLGenerator $url, - protected IUserManager $userManager + protected IUserManager $userManager, ) { } @@ -69,19 +53,19 @@ class Notifier implements INotifier { * @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 * @throws AlreadyProcessedException When the notification is not needed anymore and should be deleted * @since 9.0.0 */ public function prepare(INotification $notification, string $languageCode): INotification { if ($notification->getApp() !== 'comments') { - throw new \InvalidArgumentException(); + throw new UnknownNotificationException(); } try { $comment = $this->commentsManager->get($notification->getObjectId()); } catch (NotFoundException $e) { // needs to be converted to InvalidArgumentException, otherwise none Notifications will be shown at all - throw new \InvalidArgumentException('Comment not found', 0, $e); + throw new UnknownNotificationException('Comment not found', 0, $e); } $l = $this->l10nFactory->get('comments', $languageCode); $displayName = $comment->getActorId(); @@ -97,7 +81,7 @@ class Notifier implements INotifier { case 'mention': $parameters = $notification->getSubjectParameters(); if ($parameters[0] !== 'files') { - throw new \InvalidArgumentException('Unsupported comment object'); + throw new UnknownNotificationException('Unsupported comment object'); } $userFolder = $this->rootFolder->getUserFolder($notification->getUser()); $nodes = $userFolder->getById((int)$parameters[1]); @@ -145,7 +129,7 @@ class Notifier implements INotifier { break; default: - throw new \InvalidArgumentException('Invalid subject'); + throw new UnknownNotificationException('Invalid subject'); } } |