mirror of
https://github.com/nextcloud/server.git
synced 2026-02-03 20:41:22 -05:00
feat(notifications): Migrate server INotifiers to new exceptions
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
9496ce6c7a
commit
8130968a35
14 changed files with 65 additions and 54 deletions
|
|
@ -17,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(
|
||||
|
|
@ -52,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();
|
||||
|
|
@ -80,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]);
|
||||
|
|
@ -128,7 +129,7 @@ class Notifier implements INotifier {
|
|||
break;
|
||||
|
||||
default:
|
||||
throw new \InvalidArgumentException('Invalid subject');
|
||||
throw new UnknownNotificationException('Invalid subject');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,9 @@ use OCP\IL10N;
|
|||
use OCP\IURLGenerator;
|
||||
use OCP\IUserManager;
|
||||
use OCP\L10N\IFactory;
|
||||
use OCP\Notification\AlreadyProcessedException;
|
||||
use OCP\Notification\INotification;
|
||||
use OCP\Notification\UnknownNotificationException;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Test\TestCase;
|
||||
|
||||
|
|
@ -304,7 +306,7 @@ class NotifierTest extends TestCase {
|
|||
|
||||
|
||||
public function testPrepareDifferentApp() {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectException(UnknownNotificationException::class);
|
||||
|
||||
$this->folder
|
||||
->expects($this->never())
|
||||
|
|
@ -341,7 +343,7 @@ class NotifierTest extends TestCase {
|
|||
|
||||
|
||||
public function testPrepareNotFound() {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectException(UnknownNotificationException::class);
|
||||
|
||||
$this->folder
|
||||
->expects($this->never())
|
||||
|
|
@ -379,7 +381,7 @@ class NotifierTest extends TestCase {
|
|||
|
||||
|
||||
public function testPrepareDifferentSubject() {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectException(UnknownNotificationException::class);
|
||||
|
||||
$displayName = 'Huraga';
|
||||
|
||||
|
|
@ -436,7 +438,7 @@ class NotifierTest extends TestCase {
|
|||
|
||||
|
||||
public function testPrepareNotFiles() {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectException(UnknownNotificationException::class);
|
||||
|
||||
$displayName = 'Huraga';
|
||||
|
||||
|
|
@ -494,7 +496,7 @@ class NotifierTest extends TestCase {
|
|||
|
||||
|
||||
public function testPrepareUnresolvableFileID() {
|
||||
$this->expectException(\OCP\Notification\AlreadyProcessedException::class);
|
||||
$this->expectException(AlreadyProcessedException::class);
|
||||
|
||||
$displayName = 'Huraga';
|
||||
|
||||
|
|
|
|||
|
|
@ -17,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
|
||||
|
|
@ -78,12 +79,12 @@ 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 \Exception
|
||||
* @throws UnknownNotificationException
|
||||
*/
|
||||
public function prepare(INotification $notification,
|
||||
string $languageCode):INotification {
|
||||
if ($notification->getApp() !== Application::APP_ID) {
|
||||
throw new \InvalidArgumentException('Notification not from this app');
|
||||
throw new UnknownNotificationException('Notification not from this app');
|
||||
}
|
||||
|
||||
// Read the language from the notification
|
||||
|
|
@ -95,7 +96,7 @@ class Notifier implements INotifier {
|
|||
return $this->prepareReminderNotification($notification);
|
||||
|
||||
default:
|
||||
throw new \InvalidArgumentException('Unknown subject');
|
||||
throw new UnknownNotificationException('Unknown subject');
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use OCP\IURLGenerator;
|
|||
use OCP\L10N\IFactory;
|
||||
use OCP\Notification\AlreadyProcessedException;
|
||||
use OCP\Notification\INotification;
|
||||
use OCP\Notification\UnknownNotificationException;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Test\TestCase;
|
||||
|
||||
|
|
@ -88,7 +89,7 @@ class NotifierTest extends TestCase {
|
|||
|
||||
|
||||
public function testPrepareWrongApp(): void {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectException(UnknownNotificationException::class);
|
||||
$this->expectExceptionMessage('Notification not from this app');
|
||||
|
||||
/** @var INotification|MockObject $notification */
|
||||
|
|
@ -105,7 +106,7 @@ class NotifierTest extends TestCase {
|
|||
|
||||
|
||||
public function testPrepareWrongSubject(): void {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectException(UnknownNotificationException::class);
|
||||
$this->expectExceptionMessage('Unknown subject');
|
||||
|
||||
/** @var INotification|MockObject $notification */
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ use OCP\IURLGenerator;
|
|||
use OCP\L10N\IFactory;
|
||||
use OCP\Notification\INotification;
|
||||
use OCP\Notification\INotifier;
|
||||
use OCP\Notification\UnknownNotificationException;
|
||||
|
||||
class Notifier implements INotifier {
|
||||
/** @var IFactory */
|
||||
|
|
@ -65,12 +66,12 @@ 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
|
||||
* @throws UnknownNotificationException
|
||||
*/
|
||||
public function prepare(INotification $notification, string $languageCode): INotification {
|
||||
if ($notification->getApp() !== 'files_sharing' || $notification->getObjectType() !== 'remote_share') {
|
||||
// Not my app => throw
|
||||
throw new \InvalidArgumentException();
|
||||
throw new UnknownNotificationException();
|
||||
}
|
||||
|
||||
// Read the language from the notification
|
||||
|
|
@ -141,7 +142,7 @@ class Notifier implements INotifier {
|
|||
|
||||
default:
|
||||
// Unknown subject => Unknown notification => throw
|
||||
throw new \InvalidArgumentException();
|
||||
throw new UnknownNotificationException();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ use OCP\Notification\IDismissableNotifier;
|
|||
use OCP\Notification\IManager;
|
||||
use OCP\Notification\INotification;
|
||||
use OCP\Notification\INotifier;
|
||||
use OCP\Notification\UnknownNotificationException;
|
||||
|
||||
class Notifier implements INotifier, IDismissableNotifier {
|
||||
/** @var IFactory */
|
||||
|
|
@ -62,11 +63,11 @@ class Notifier implements INotifier, IDismissableNotifier {
|
|||
* @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() !== 'files') {
|
||||
throw new \InvalidArgumentException('Unhandled app');
|
||||
throw new UnknownNotificationException('Unhandled app');
|
||||
}
|
||||
|
||||
return match($notification->getSubject()) {
|
||||
|
|
@ -76,7 +77,7 @@ class Notifier implements INotifier, IDismissableNotifier {
|
|||
'transferOwnershipFailedTarget' => $this->handleTransferOwnershipFailedTarget($notification, $languageCode),
|
||||
'transferOwnershipDoneSource' => $this->handleTransferOwnershipDoneSource($notification, $languageCode),
|
||||
'transferOwnershipDoneTarget' => $this->handleTransferOwnershipDoneTarget($notification, $languageCode),
|
||||
default => throw new \InvalidArgumentException('Unhandled subject')
|
||||
default => throw new UnknownNotificationException('Unhandled subject')
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -256,7 +257,7 @@ class Notifier implements INotifier, IDismissableNotifier {
|
|||
|
||||
public function dismissNotification(INotification $notification): void {
|
||||
if ($notification->getApp() !== 'files') {
|
||||
throw new \InvalidArgumentException('Unhandled app');
|
||||
throw new UnknownNotificationException('Unhandled app');
|
||||
}
|
||||
|
||||
// TODO: This should all be moved to a service that also the transferownershipController uses.
|
||||
|
|
|
|||
|
|
@ -9,16 +9,15 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\FilesReminders\Notification;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use OCA\FilesReminders\AppInfo\Application;
|
||||
use OCP\Files\FileInfo;
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\L10N\IFactory;
|
||||
use OCP\Notification\AlreadyProcessedException;
|
||||
use OCP\Notification\IAction;
|
||||
use OCP\Notification\INotification;
|
||||
use OCP\Notification\INotifier;
|
||||
use OCP\Notification\UnknownNotificationException;
|
||||
|
||||
class Notifier implements INotifier {
|
||||
public function __construct(
|
||||
|
|
@ -37,14 +36,13 @@ class Notifier implements INotifier {
|
|||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidArgumentException
|
||||
* @throws AlreadyProcessedException
|
||||
* @throws UnknownNotificationException
|
||||
*/
|
||||
public function prepare(INotification $notification, string $languageCode): INotification {
|
||||
$l = $this->l10nFactory->get(Application::APP_ID, $languageCode);
|
||||
|
||||
if ($notification->getApp() !== Application::APP_ID) {
|
||||
throw new InvalidArgumentException();
|
||||
throw new UnknownNotificationException();
|
||||
}
|
||||
|
||||
switch ($notification->getSubject()) {
|
||||
|
|
@ -54,7 +52,7 @@ class Notifier implements INotifier {
|
|||
|
||||
$node = $this->root->getUserFolder($notification->getUser())->getFirstNodeById($fileId);
|
||||
if (!$node) {
|
||||
throw new InvalidArgumentException();
|
||||
throw new UnknownNotificationException();
|
||||
}
|
||||
|
||||
$path = rtrim($node->getPath(), '/');
|
||||
|
|
@ -92,8 +90,7 @@ class Notifier implements INotifier {
|
|||
$this->addActionButton($notification, $label);
|
||||
break;
|
||||
default:
|
||||
throw new InvalidArgumentException();
|
||||
break;
|
||||
throw new UnknownNotificationException();
|
||||
}
|
||||
|
||||
return $notification;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ use OCP\L10N\IFactory;
|
|||
use OCP\Notification\AlreadyProcessedException;
|
||||
use OCP\Notification\INotification;
|
||||
use OCP\Notification\INotifier;
|
||||
use OCP\Notification\UnknownNotificationException;
|
||||
use OCP\Share\Exceptions\ShareNotFound;
|
||||
use OCP\Share\IManager;
|
||||
use OCP\Share\IShare;
|
||||
|
|
@ -78,7 +79,7 @@ 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
|
||||
*/
|
||||
|
|
@ -86,7 +87,7 @@ class Notifier implements INotifier {
|
|||
if ($notification->getApp() !== 'files_sharing' ||
|
||||
($notification->getSubject() !== 'expiresTomorrow' &&
|
||||
$notification->getObjectType() !== 'share')) {
|
||||
throw new \InvalidArgumentException('Unhandled app or subject');
|
||||
throw new UnknownNotificationException('Unhandled app or subject');
|
||||
}
|
||||
|
||||
$l = $this->l10nFactory->get('files_sharing', $languageCode);
|
||||
|
|
@ -145,7 +146,7 @@ class Notifier implements INotifier {
|
|||
throw new AlreadyProcessedException();
|
||||
}
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Invalid share type');
|
||||
throw new UnknownNotificationException('Invalid share type');
|
||||
}
|
||||
|
||||
switch ($notification->getSubject()) {
|
||||
|
|
@ -216,7 +217,7 @@ class Notifier implements INotifier {
|
|||
break;
|
||||
|
||||
default:
|
||||
throw new \InvalidArgumentException('Invalid subject');
|
||||
throw new UnknownNotificationException('Invalid subject');
|
||||
}
|
||||
|
||||
$notification->setRichSubject($subject, $subjectParameters)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use OCP\IURLGenerator;
|
|||
use OCP\L10N\IFactory;
|
||||
use OCP\Notification\INotification;
|
||||
use OCP\Notification\INotifier;
|
||||
use OCP\Notification\UnknownNotificationException;
|
||||
|
||||
class Notifier implements INotifier {
|
||||
|
||||
|
|
@ -49,7 +50,7 @@ class Notifier implements INotifier {
|
|||
public function prepare(INotification $notification, string $languageCode): INotification {
|
||||
if ($notification->getApp() !== 'twofactor_backupcodes') {
|
||||
// Not my app => throw
|
||||
throw new \InvalidArgumentException();
|
||||
throw new UnknownNotificationException();
|
||||
}
|
||||
|
||||
// Read the language from the notification
|
||||
|
|
@ -71,7 +72,7 @@ class Notifier implements INotifier {
|
|||
|
||||
default:
|
||||
// Unknown subject => Unknown notification => throw
|
||||
throw new \InvalidArgumentException();
|
||||
throw new UnknownNotificationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,10 +13,12 @@ use OCP\App\IAppManager;
|
|||
use OCP\IURLGenerator;
|
||||
use OCP\IUserManager;
|
||||
use OCP\L10N\IFactory;
|
||||
use OCP\Notification\AlreadyProcessedException;
|
||||
use OCP\Notification\IAction;
|
||||
use OCP\Notification\IManager as INotificationManager;
|
||||
use OCP\Notification\INotification;
|
||||
use OCP\Notification\INotifier;
|
||||
use OCP\Notification\UnknownNotificationException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class AppUpdateNotifier implements INotifier {
|
||||
|
|
@ -46,26 +48,27 @@ class AppUpdateNotifier 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 app is no longer known
|
||||
*/
|
||||
public function prepare(INotification $notification, string $languageCode): INotification {
|
||||
if ($notification->getApp() !== Application::APP_NAME) {
|
||||
throw new \InvalidArgumentException('Unknown app');
|
||||
throw new UnknownNotificationException('Unknown app');
|
||||
}
|
||||
|
||||
if ($notification->getSubject() !== 'app_updated') {
|
||||
throw new \InvalidArgumentException('Unknown subject');
|
||||
throw new UnknownNotificationException('Unknown subject');
|
||||
}
|
||||
|
||||
$appId = $notification->getSubjectParameters()[0];
|
||||
$appInfo = $this->appManager->getAppInfo($appId, lang:$languageCode);
|
||||
if ($appInfo === null) {
|
||||
throw new \InvalidArgumentException('App info not found');
|
||||
throw new AlreadyProcessedException();
|
||||
}
|
||||
|
||||
// Prepare translation factory for requested language
|
||||
$l = $this->l10nFactory->get(Application::APP_NAME, $languageCode);
|
||||
|
||||
|
||||
$icon = $this->appManager->getAppIcon($appId, true);
|
||||
if ($icon === null) {
|
||||
$icon = $this->urlGenerator->imagePath('core', 'actions/change.svg');
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ use OCP\Notification\AlreadyProcessedException;
|
|||
use OCP\Notification\IManager;
|
||||
use OCP\Notification\INotification;
|
||||
use OCP\Notification\INotifier;
|
||||
use OCP\Notification\UnknownNotificationException;
|
||||
use OCP\Util;
|
||||
|
||||
class Notifier implements INotifier {
|
||||
|
|
@ -87,25 +88,24 @@ 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() !== 'updatenotification') {
|
||||
throw new \InvalidArgumentException('Unknown app id');
|
||||
throw new UnknownNotificationException('Unknown app id');
|
||||
}
|
||||
|
||||
if ($notification->getSubject() !== 'update_available' && $notification->getSubject() !== 'connection_error') {
|
||||
throw new \InvalidArgumentException('Unknown subject');
|
||||
throw new UnknownNotificationException('Unknown subject');
|
||||
}
|
||||
|
||||
$l = $this->l10NFactory->get('updatenotification', $languageCode);
|
||||
if ($notification->getSubject() === 'connection_error') {
|
||||
$errors = (int) $this->config->getAppValue('updatenotification', 'update_check_errors', '0');
|
||||
if ($errors === 0) {
|
||||
$this->notificationManager->markProcessed($notification);
|
||||
throw new \InvalidArgumentException('Update checked worked again');
|
||||
throw new AlreadyProcessedException();
|
||||
}
|
||||
|
||||
$notification->setParsedSubject($l->t('The update server could not be reached since %d days to check for new updates.', [$errors]))
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ namespace OCA\User_LDAP\Notification;
|
|||
use OCP\L10N\IFactory;
|
||||
use OCP\Notification\INotification;
|
||||
use OCP\Notification\INotifier;
|
||||
use OCP\Notification\UnknownNotificationException;
|
||||
|
||||
class Notifier implements INotifier {
|
||||
|
||||
|
|
@ -45,12 +46,12 @@ 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
|
||||
*/
|
||||
public function prepare(INotification $notification, string $languageCode): INotification {
|
||||
if ($notification->getApp() !== 'user_ldap') {
|
||||
// Not my app => throw
|
||||
throw new \InvalidArgumentException();
|
||||
throw new UnknownNotificationException();
|
||||
}
|
||||
|
||||
// Read the language from the notification
|
||||
|
|
@ -76,7 +77,7 @@ class Notifier implements INotifier {
|
|||
|
||||
default:
|
||||
// Unknown subject => Unknown notification => throw
|
||||
throw new \InvalidArgumentException();
|
||||
throw new UnknownNotificationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use OCP\L10N\IFactory;
|
|||
use OCP\Notification\IAction;
|
||||
use OCP\Notification\INotification;
|
||||
use OCP\Notification\INotifier;
|
||||
use OCP\Notification\UnknownNotificationException;
|
||||
|
||||
class CoreNotifier implements INotifier {
|
||||
public function __construct(
|
||||
|
|
@ -45,7 +46,7 @@ class CoreNotifier implements INotifier {
|
|||
|
||||
public function prepare(INotification $notification, string $languageCode): INotification {
|
||||
if ($notification->getApp() !== 'core') {
|
||||
throw new \InvalidArgumentException();
|
||||
throw new UnknownNotificationException();
|
||||
}
|
||||
$l = $this->factory->get('core', $languageCode);
|
||||
|
||||
|
|
@ -71,6 +72,6 @@ class CoreNotifier implements INotifier {
|
|||
return $notification;
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('Invalid subject');
|
||||
throw new UnknownNotificationException('Invalid subject');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ declare(strict_types=1);
|
|||
*/
|
||||
namespace OC\Authentication\Notifications;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use OCP\L10N\IFactory as IL10nFactory;
|
||||
use OCP\Notification\INotification;
|
||||
use OCP\Notification\INotifier;
|
||||
use OCP\Notification\UnknownNotificationException;
|
||||
|
||||
class Notifier implements INotifier {
|
||||
/** @var IL10nFactory */
|
||||
|
|
@ -27,7 +27,7 @@ class Notifier implements INotifier {
|
|||
public function prepare(INotification $notification, string $languageCode): INotification {
|
||||
if ($notification->getApp() !== 'auth') {
|
||||
// Not my app => throw
|
||||
throw new InvalidArgumentException();
|
||||
throw new UnknownNotificationException();
|
||||
}
|
||||
|
||||
// Read the language from the notification
|
||||
|
|
@ -52,7 +52,7 @@ class Notifier implements INotifier {
|
|||
return $notification;
|
||||
default:
|
||||
// Unknown subject => Unknown notification => throw
|
||||
throw new InvalidArgumentException();
|
||||
throw new UnknownNotificationException();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue