Skip to content

Commit

Permalink
refactor: move to new activity exception
Browse files Browse the repository at this point in the history
Signed-off-by: Anna Larch <anna@nextcloud.com>
  • Loading branch information
miaulalala committed Sep 16, 2024
1 parent c3ca897 commit 06f914e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/Activity/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
namespace OCA\TwoFactorTOTP\Activity;

use InvalidArgumentException;
use OCP\Activity\Exceptions\UnknownActivityException;
use OCP\Activity\IEvent;
use OCP\Activity\IProvider;
use OCP\IURLGenerator;
Expand All @@ -43,9 +44,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);
Expand All @@ -61,6 +62,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;
}
Expand Down

0 comments on commit 06f914e

Please sign in to comment.