Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move to new activity exception #1560

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/Activity/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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;
}
Expand Down
Loading