Skip to content

Commit

Permalink
fix: change error class
Browse files Browse the repository at this point in the history
since 30.0.0:

Providers should throw `UnknownActivityException` instead of `\InvalidArgumentException`
  when they did not handle the event. Throwing `\InvalidArgumentException` directly is deprecated and will
  be logged as an error in Nextcloud 39.

Signed-off-by: Vitor Mattos <[email protected]>
  • Loading branch information
vitormattos authored and backportbot-libresign[bot] committed Dec 12, 2024
1 parent b33aa5b commit a3a6692
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/Activity/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use OCA\Libresign\Events\SendSignNotificationEvent;
use OCA\Libresign\Service\AccountService;
use OCA\Libresign\Service\IdentifyMethod\IIdentifyMethod;
use OCP\Activity\Exceptions\UnknownActivityException;
use OCP\Activity\IManager;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\EventDispatcher\Event;
Expand Down Expand Up @@ -103,7 +104,7 @@ protected function generateNewSignNotificationActivity(
],
]);
$this->activityManager->publish($event);
} catch (\InvalidArgumentException $e) {
} catch (UnknownActivityException $e) {
$this->logger->error($e->getMessage(), ['exception' => $e]);
return;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Activity/Provider/SignRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace OCA\Libresign\Activity\Provider;

use OCA\Libresign\AppInfo\Application;
use OCP\Activity\Exceptions\UnknownActivityException;
use OCP\Activity\IEvent;
use OCP\Activity\IManager;
use OCP\Activity\IProvider;
Expand All @@ -29,7 +30,7 @@ public function __construct(

public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent {
if ($event->getApp() !== Application::APP_ID) {
throw new \InvalidArgumentException('Wrong app');
throw new UnknownActivityException('Wrong app');
}

$this->definitions->definitions['sign-request'] = [
Expand Down
5 changes: 3 additions & 2 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use OCA\Libresign\AppInfo\Application;
use OCA\Libresign\Db\FileMapper;
use OCA\Libresign\Db\SignRequestMapper;
use OCP\Activity\Exceptions\UnknownActivityException;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\L10N\IFactory;
Expand Down Expand Up @@ -39,7 +40,7 @@ public function getName(): string {

public function prepare(INotification $notification, string $languageCode): INotification {
if ($notification->getApp() !== Application::APP_ID) {
throw new \InvalidArgumentException();
throw new UnknownActivityException();
}

$this->definitions->definitions['sign-request'] = [
Expand Down Expand Up @@ -69,7 +70,7 @@ public function prepare(INotification $notification, string $languageCode): INot
case 'update_sign_request':
return $this->parseSignRequest($notification, $l, true);
default:
throw new \InvalidArgumentException();
throw new UnknownActivityException();
}
}

Expand Down

0 comments on commit a3a6692

Please sign in to comment.