diff options
Diffstat (limited to 'apps/dav/lib/CardDAV/Activity')
-rw-r--r-- | apps/dav/lib/CardDAV/Activity/Backend.php | 75 | ||||
-rw-r--r-- | apps/dav/lib/CardDAV/Activity/Filter.php | 39 | ||||
-rw-r--r-- | apps/dav/lib/CardDAV/Activity/Provider/Addressbook.php | 48 | ||||
-rw-r--r-- | apps/dav/lib/CardDAV/Activity/Provider/Base.php | 51 | ||||
-rw-r--r-- | apps/dav/lib/CardDAV/Activity/Provider/Card.php | 54 | ||||
-rw-r--r-- | apps/dav/lib/CardDAV/Activity/Setting.php | 25 |
6 files changed, 68 insertions, 224 deletions
diff --git a/apps/dav/lib/CardDAV/Activity/Backend.php b/apps/dav/lib/CardDAV/Activity/Backend.php index f0a5ee05e82..b08414d3b02 100644 --- a/apps/dav/lib/CardDAV/Activity/Backend.php +++ b/apps/dav/lib/CardDAV/Activity/Backend.php @@ -3,25 +3,8 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2021 Joas Schilling <coding@schilljs.com> - * - * @author Joas Schilling <coding@schilljs.com> - * - * @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: 2021 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\DAV\CardDAV\Activity; @@ -39,31 +22,13 @@ use Sabre\VObject\Reader; class Backend { - /** @var IActivityManager */ - protected $activityManager; - - /** @var IGroupManager */ - protected $groupManager; - - /** @var IUserSession */ - protected $userSession; - - /** @var IAppManager */ - protected $appManager; - - /** @var IUserManager */ - protected $userManager; - - public function __construct(IActivityManager $activityManager, - IGroupManager $groupManager, - IUserSession $userSession, - IAppManager $appManager, - IUserManager $userManager) { - $this->activityManager = $activityManager; - $this->groupManager = $groupManager; - $this->userSession = $userSession; - $this->appManager = $appManager; - $this->userManager = $userManager; + public function __construct( + protected IActivityManager $activityManager, + protected IGroupManager $groupManager, + protected IUserSession $userSession, + protected IAppManager $appManager, + protected IUserManager $userManager, + ) { } /** @@ -128,7 +93,7 @@ class Backend { $event = $this->activityManager->generateEvent(); $event->setApp('dav') - ->setObject('addressbook', (int) $addressbookData['id']) + ->setObject('addressbook', (int)$addressbookData['id']) ->setType('contacts') ->setAuthor($currentUser); @@ -156,7 +121,7 @@ class Backend { [ 'actor' => $currentUser, 'addressbook' => [ - 'id' => (int) $addressbookData['id'], + 'id' => (int)$addressbookData['id'], 'uri' => $addressbookData['uri'], 'name' => $addressbookData['{DAV:}displayname'], ], @@ -187,7 +152,7 @@ class Backend { $event = $this->activityManager->generateEvent(); $event->setApp('dav') - ->setObject('addressbook', (int) $addressbookData['id']) + ->setObject('addressbook', (int)$addressbookData['id']) ->setType('contacts') ->setAuthor($currentUser); @@ -212,7 +177,7 @@ class Backend { $parameters = [ 'actor' => $event->getAuthor(), 'addressbook' => [ - 'id' => (int) $addressbookData['id'], + 'id' => (int)$addressbookData['id'], 'uri' => $addressbookData['uri'], 'name' => $addressbookData['{DAV:}displayname'], ], @@ -241,7 +206,7 @@ class Backend { $parameters = [ 'actor' => $event->getAuthor(), 'addressbook' => [ - 'id' => (int) $addressbookData['id'], + 'id' => (int)$addressbookData['id'], 'uri' => $addressbookData['uri'], 'name' => $addressbookData['{DAV:}displayname'], ], @@ -283,7 +248,7 @@ class Backend { $parameters = [ 'actor' => $event->getAuthor(), 'addressbook' => [ - 'id' => (int) $addressbookData['id'], + 'id' => (int)$addressbookData['id'], 'uri' => $addressbookData['uri'], 'name' => $addressbookData['{DAV:}displayname'], ], @@ -310,7 +275,7 @@ class Backend { $parameters = [ 'actor' => $event->getAuthor(), 'addressbook' => [ - 'id' => (int) $addressbookData['id'], + 'id' => (int)$addressbookData['id'], 'uri' => $addressbookData['uri'], 'name' => $addressbookData['{DAV:}displayname'], ], @@ -388,7 +353,7 @@ class Backend { [ 'actor' => $event->getAuthor(), 'addressbook' => [ - 'id' => (int) $properties['id'], + 'id' => (int)$properties['id'], 'uri' => $properties['uri'], 'name' => $properties['{DAV:}displayname'], ], @@ -432,7 +397,7 @@ class Backend { $event = $this->activityManager->generateEvent(); $event->setApp('dav') - ->setObject('addressbook', (int) $addressbookData['id']) + ->setObject('addressbook', (int)$addressbookData['id']) ->setType('contacts') ->setAuthor($currentUser); @@ -444,7 +409,7 @@ class Backend { $params = [ 'actor' => $event->getAuthor(), 'addressbook' => [ - 'id' => (int) $addressbookData['id'], + 'id' => (int)$addressbookData['id'], 'uri' => $addressbookData['uri'], 'name' => $addressbookData['{DAV:}displayname'], ], @@ -471,7 +436,7 @@ class Backend { */ protected function getCardNameAndId(array $cardData): array { $vObject = Reader::read($cardData['carddata']); - return ['id' => (string) $vObject->UID, 'name' => (string) ($vObject->FN ?? '')]; + return ['id' => (string)$vObject->UID, 'name' => (string)($vObject->FN ?? '')]; } /** diff --git a/apps/dav/lib/CardDAV/Activity/Filter.php b/apps/dav/lib/CardDAV/Activity/Filter.php index 3ca4c3367d5..8b221a29ff0 100644 --- a/apps/dav/lib/CardDAV/Activity/Filter.php +++ b/apps/dav/lib/CardDAV/Activity/Filter.php @@ -1,24 +1,8 @@ <?php + /** - * @copyright Copyright (c) 2021 Joas Schilling <coding@schilljs.com> - * - * @author Joas Schilling <coding@schilljs.com> - * - * @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: 2021 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\DAV\CardDAV\Activity; @@ -28,15 +12,10 @@ use OCP\IURLGenerator; class Filter implements IFilter { - /** @var IL10N */ - protected $l; - - /** @var IURLGenerator */ - protected $url; - - public function __construct(IL10N $l, IURLGenerator $url) { - $this->l = $l; - $this->url = $url; + public function __construct( + protected IL10N $l, + protected IURLGenerator $url, + ) { } /** @@ -55,8 +34,8 @@ class Filter implements IFilter { /** * @return int whether the filter should be rather on the top or bottom of - * the admin section. The filters are arranged in ascending order of the - * priority values. It is required to return a value between 0 and 100. + * the admin section. The filters are arranged in ascending order of the + * priority values. It is required to return a value between 0 and 100. */ public function getPriority(): int { return 40; diff --git a/apps/dav/lib/CardDAV/Activity/Provider/Addressbook.php b/apps/dav/lib/CardDAV/Activity/Provider/Addressbook.php index a404dde4448..cdb9769401f 100644 --- a/apps/dav/lib/CardDAV/Activity/Provider/Addressbook.php +++ b/apps/dav/lib/CardDAV/Activity/Provider/Addressbook.php @@ -3,28 +3,12 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2021 Joas Schilling <coding@schilljs.com> - * - * @author Joas Schilling <coding@schilljs.com> - * - * @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: 2021 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\DAV\CardDAV\Activity\Provider; +use OCP\Activity\Exceptions\UnknownActivityException; use OCP\Activity\IEvent; use OCP\Activity\IEventMerger; use OCP\Activity\IManager; @@ -43,25 +27,15 @@ class Addressbook extends Base { public const SUBJECT_UNSHARE_USER = 'addressbook_user_unshare'; public const SUBJECT_UNSHARE_GROUP = 'addressbook_group_unshare'; - /** @var IFactory */ - protected $languageFactory; - - /** @var IManager */ - protected $activityManager; - - /** @var IEventMerger */ - protected $eventMerger; - - public function __construct(IFactory $languageFactory, + public function __construct( + protected IFactory $languageFactory, IURLGenerator $url, - IManager $activityManager, + protected IManager $activityManager, IUserManager $userManager, IGroupManager $groupManager, - IEventMerger $eventMerger) { + protected IEventMerger $eventMerger, + ) { parent::__construct($userManager, $groupManager, $url); - $this->languageFactory = $languageFactory; - $this->activityManager = $activityManager; - $this->eventMerger = $eventMerger; } /** @@ -69,11 +43,11 @@ class Addressbook extends Base { * @param IEvent $event * @param IEvent|null $previousEvent * @return IEvent - * @throws \InvalidArgumentException + * @throws UnknownActivityException */ public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent { if ($event->getApp() !== 'dav' || $event->getType() !== 'contacts') { - throw new \InvalidArgumentException(); + throw new UnknownActivityException(); } $l = $this->languageFactory->get('dav', $language); @@ -119,7 +93,7 @@ class Addressbook extends Base { } elseif ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP . '_by') { $subject = $l->t('{actor} unshared address book {addressbook} from group {group}'); } else { - throw new \InvalidArgumentException(); + throw new UnknownActivityException(); } $parsedParameters = $this->getParameters($event, $l); diff --git a/apps/dav/lib/CardDAV/Activity/Provider/Base.php b/apps/dav/lib/CardDAV/Activity/Provider/Base.php index f475f9d76b7..ea7680aed60 100644 --- a/apps/dav/lib/CardDAV/Activity/Provider/Base.php +++ b/apps/dav/lib/CardDAV/Activity/Provider/Base.php @@ -3,25 +3,8 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2021 Joas Schilling <coding@schilljs.com> - * - * @author Joas Schilling <coding@schilljs.com> - * - * @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: 2021 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\DAV\CardDAV\Activity\Provider; @@ -35,27 +18,17 @@ use OCP\IURLGenerator; use OCP\IUserManager; abstract class Base implements IProvider { - /** @var IUserManager */ - protected $userManager; - - /** @var string[] */ + /** @var string[] */ protected $userDisplayNames = []; - /** @var IGroupManager */ - protected $groupManager; - /** @var string[] */ protected $groupDisplayNames = []; - /** @var IURLGenerator */ - protected $url; - - public function __construct(IUserManager $userManager, - IGroupManager $groupManager, - IURLGenerator $urlGenerator) { - $this->userManager = $userManager; - $this->groupManager = $groupManager; - $this->url = $urlGenerator; + public function __construct( + protected IUserManager $userManager, + protected IGroupManager $groupManager, + protected IURLGenerator $url, + ) { } protected function setSubjects(IEvent $event, string $subject, array $parameters): void { @@ -68,18 +41,18 @@ abstract class Base implements IProvider { * @return array */ protected function generateAddressbookParameter(array $data, IL10N $l): array { - if ($data['uri'] === CardDavBackend::PERSONAL_ADDRESSBOOK_URI && - $data['name'] === CardDavBackend::PERSONAL_ADDRESSBOOK_NAME) { + if ($data['uri'] === CardDavBackend::PERSONAL_ADDRESSBOOK_URI + && $data['name'] === CardDavBackend::PERSONAL_ADDRESSBOOK_NAME) { return [ 'type' => 'addressbook', - 'id' => $data['id'], + 'id' => (string)$data['id'], 'name' => $l->t('Personal'), ]; } return [ 'type' => 'addressbook', - 'id' => $data['id'], + 'id' => (string)$data['id'], 'name' => $data['name'], ]; } diff --git a/apps/dav/lib/CardDAV/Activity/Provider/Card.php b/apps/dav/lib/CardDAV/Activity/Provider/Card.php index 7f49a428cae..acf23c00531 100644 --- a/apps/dav/lib/CardDAV/Activity/Provider/Card.php +++ b/apps/dav/lib/CardDAV/Activity/Provider/Card.php @@ -3,28 +3,12 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2021 Joas Schilling <coding@schilljs.com> - * - * @author Joas Schilling <coding@schilljs.com> - * - * @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: 2021 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\DAV\CardDAV\Activity\Provider; +use OCP\Activity\Exceptions\UnknownActivityException; use OCP\Activity\IEvent; use OCP\Activity\IEventMerger; use OCP\Activity\IManager; @@ -40,30 +24,16 @@ class Card extends Base { public const SUBJECT_UPDATE = 'card_update'; public const SUBJECT_DELETE = 'card_delete'; - /** @var IFactory */ - protected $languageFactory; - - /** @var IManager */ - protected $activityManager; - - /** @var IEventMerger */ - protected $eventMerger; - - /** @var IAppManager */ - protected $appManager; - - public function __construct(IFactory $languageFactory, + public function __construct( + protected IFactory $languageFactory, IURLGenerator $url, - IManager $activityManager, + protected IManager $activityManager, IUserManager $userManager, IGroupManager $groupManager, - IEventMerger $eventMerger, - IAppManager $appManager) { + protected IEventMerger $eventMerger, + protected IAppManager $appManager, + ) { parent::__construct($userManager, $groupManager, $url); - $this->languageFactory = $languageFactory; - $this->activityManager = $activityManager; - $this->eventMerger = $eventMerger; - $this->appManager = $appManager; } /** @@ -71,11 +41,11 @@ class Card extends Base { * @param IEvent $event * @param IEvent|null $previousEvent * @return IEvent - * @throws \InvalidArgumentException + * @throws UnknownActivityException */ public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent { if ($event->getApp() !== 'dav' || $event->getType() !== 'contacts') { - throw new \InvalidArgumentException(); + throw new UnknownActivityException(); } $l = $this->languageFactory->get('dav', $language); @@ -99,7 +69,7 @@ class Card extends Base { } elseif ($event->getSubject() === self::SUBJECT_UPDATE . '_self') { $subject = $l->t('You updated contact {card} in address book {addressbook}'); } else { - throw new \InvalidArgumentException(); + throw new UnknownActivityException(); } $parsedParameters = $this->getParameters($event, $l); diff --git a/apps/dav/lib/CardDAV/Activity/Setting.php b/apps/dav/lib/CardDAV/Activity/Setting.php index a8a83111dde..cc68cf87c83 100644 --- a/apps/dav/lib/CardDAV/Activity/Setting.php +++ b/apps/dav/lib/CardDAV/Activity/Setting.php @@ -3,25 +3,8 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2021 Joas Schilling <coding@schilljs.com> - * - * @author Joas Schilling <coding@schilljs.com> - * - * @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: 2021 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\DAV\CardDAV\Activity; @@ -44,8 +27,8 @@ class Setting extends CalDAVSetting { /** * @return int whether the filter should be rather on the top or bottom of - * the admin section. The filters are arranged in ascending order of the - * priority values. It is required to return a value between 0 and 100. + * the admin section. The filters are arranged in ascending order of the + * priority values. It is required to return a value between 0 and 100. */ public function getPriority(): int { return 50; |