From 52ba630996ed76a47a051973cb1bab37540860cf Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Mon, 16 Sep 2024 15:13:58 +0200 Subject: [PATCH] refactor: move to new activity exception Signed-off-by: Anna Larch --- lib/Activity/Provider.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Activity/Provider.php b/lib/Activity/Provider.php index fbc41d3c7..9f384539e 100644 --- a/lib/Activity/Provider.php +++ b/lib/Activity/Provider.php @@ -24,7 +24,7 @@ namespace OCA\TwoFactorTOTP\Activity; -use InvalidArgumentException; +use OCP\Activity\Exceptions\UnknownActivityException; use OCP\Activity\IEvent; use OCP\Activity\IProvider; use OCP\IURLGenerator; @@ -43,9 +43,9 @@ public function __construct(L10nFactory $l10n, IURLGenerator $urlGenerator) { $this->l10n = $l10n; } - public function parse($language, IEvent $event, IEvent $previousEvent = null): IEvent { + public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent { if ($event->getApp() !== 'twofactor_totp') { - throw new InvalidArgumentException(); + throw new UnknownActivityException(); } $l = $this->l10n->get('twofactor_totp', $language); @@ -61,6 +61,8 @@ public function parse($language, IEvent $event, IEvent $previousEvent = null): I case 'totp_disabled_by_admin': $event->setSubject($l->t('TOTP two-factor authentication disabled by an admin')); break; + default: + throw new UnknownActivityException(); } return $event; }