Skip to content
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
12 changes: 6 additions & 6 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

namespace OCA\Assistant\Notification;

use InvalidArgumentException;
use OCA\Assistant\AppInfo\Application;
use OCP\Activity\Exceptions\UnknownActivityException;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the notifier you need to throw OCP\Notification\UnknownNotificationException

the UnknownActivityException exception is only for activity parsing 🙈

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aaah damn

use OCP\App\IAppManager;
use OCP\IURLGenerator;
use OCP\L10N\IFactory;
Expand Down Expand Up @@ -57,13 +57,13 @@ public function getName(): string {
* @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 UnknownActivityException When the notification was not prepared by a notifier
* @since 9.0.0
*/
public function prepare(INotification $notification, string $languageCode): INotification {
if ($notification->getApp() !== Application::APP_ID) {
// Not my app => throw
throw new InvalidArgumentException();
throw new UnknownActivityException();
}

$l = $this->factory->get(Application::APP_ID, $languageCode);
Expand All @@ -73,12 +73,12 @@ public function prepare(INotification $notification, string $languageCode): INot
if (in_array($notification->getSubject(), ['success', 'failure'], true)) {
// ignore old notifications (before meta tasks were introduced)
if (!isset($params['target'], $params['inputs'])) {
throw new InvalidArgumentException();
throw new UnknownActivityException();
}
$schedulingAppId = $params['appId'];
$schedulingAppInfo = $this->appManager->getAppInfo($schedulingAppId);
if ($schedulingAppInfo === null) {
throw new InvalidArgumentException();
throw new UnknownActivityException();
}
$schedulingAppName = $schedulingAppInfo['name'];

Expand Down Expand Up @@ -415,7 +415,7 @@ public function prepare(INotification $notification, string $languageCode): INot

default:
// Unknown subject => Unknown notification => throw
throw new InvalidArgumentException();
throw new UnknownActivityException();
}
}
}
Loading