aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/lib/Activity/Provider.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings/lib/Activity/Provider.php')
-rw-r--r--apps/settings/lib/Activity/Provider.php70
1 files changed, 17 insertions, 53 deletions
diff --git a/apps/settings/lib/Activity/Provider.php b/apps/settings/lib/Activity/Provider.php
index e10e55b5750..c31a900abd5 100644
--- a/apps/settings/lib/Activity/Provider.php
+++ b/apps/settings/lib/Activity/Provider.php
@@ -3,31 +3,12 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Daniel Kesselberg <mail@danielkesselberg.de>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Thomas Citharel <nextcloud@tcit.fr>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Settings\Activity;
+use OCP\Activity\Exceptions\UnknownActivityException;
use OCP\Activity\IEvent;
use OCP\Activity\IManager;
use OCP\Activity\IProvider;
@@ -50,29 +31,15 @@ class Provider implements IProvider {
public const APP_TOKEN_FILESYSTEM_GRANTED = 'app_token_filesystem_granted';
public const APP_TOKEN_FILESYSTEM_REVOKED = 'app_token_filesystem_revoked';
- /** @var IFactory */
- protected $languageFactory;
-
/** @var IL10N */
protected $l;
- /** @var IURLGenerator */
- protected $url;
-
- /** @var IUserManager */
- protected $userManager;
-
- /** @var IManager */
- private $activityManager;
-
- public function __construct(IFactory $languageFactory,
- IURLGenerator $url,
- IUserManager $userManager,
- IManager $activityManager) {
- $this->languageFactory = $languageFactory;
- $this->url = $url;
- $this->userManager = $userManager;
- $this->activityManager = $activityManager;
+ public function __construct(
+ protected IFactory $languageFactory,
+ protected IURLGenerator $url,
+ protected IUserManager $userManager,
+ private IManager $activityManager,
+ ) {
}
/**
@@ -80,12 +47,12 @@ class Provider implements IProvider {
* @param IEvent $event
* @param IEvent|null $previousEvent
* @return IEvent
- * @throws \InvalidArgumentException
+ * @throws UnknownActivityException
* @since 11.0.0
*/
public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent {
if ($event->getApp() !== 'settings') {
- throw new \InvalidArgumentException('Unknown app');
+ throw new UnknownActivityException('Unknown app');
}
$this->l = $this->languageFactory->get('settings', $language);
@@ -125,7 +92,7 @@ class Provider implements IProvider {
} elseif ($event->getSubject() === self::APP_TOKEN_FILESYSTEM_REVOKED) {
$subject = $this->l->t('You revoked filesystem access from app password "{token}"');
} else {
- throw new \InvalidArgumentException('Unknown subject');
+ throw new UnknownActivityException('Unknown subject');
}
$parsedParameters = $this->getParameters($event);
@@ -137,7 +104,7 @@ class Provider implements IProvider {
/**
* @param IEvent $event
* @return array
- * @throws \InvalidArgumentException
+ * @throws UnknownActivityException
*/
protected function getParameters(IEvent $event): array {
$subject = $event->getSubject();
@@ -162,7 +129,7 @@ class Provider implements IProvider {
return [
'token' => [
'type' => 'highlight',
- 'id' => $event->getObjectId(),
+ 'id' => (string)$event->getObjectId(),
'name' => $parameters['name'],
]
];
@@ -170,23 +137,20 @@ class Provider implements IProvider {
return [
'token' => [
'type' => 'highlight',
- 'id' => $event->getObjectId(),
+ 'id' => (string)$event->getObjectId(),
'name' => $parameters['name'],
],
'newToken' => [
'type' => 'highlight',
- 'id' => $event->getObjectId(),
+ 'id' => (string)$event->getObjectId(),
'name' => $parameters['newName'],
]
];
}
- throw new \InvalidArgumentException('Unknown subject');
+ throw new UnknownActivityException('Unknown subject');
}
- /**
- * @throws \InvalidArgumentException
- */
protected function setSubjects(IEvent $event, string $subject, array $parameters): void {
$event->setRichSubject($subject, $parameters);
}