From 1ce46c1fca9797bb2bd5c160c5976eeec828ae32 Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Mon, 16 Sep 2024 15:09:39 +0200 Subject: [PATCH] refactor: move to new activity exception Signed-off-by: Anna Larch --- apps/comments/lib/Activity/Provider.php | 9 +++++---- apps/dav/lib/CalDAV/Activity/Provider/Calendar.php | 7 ++++--- apps/dav/lib/CalDAV/Activity/Provider/Event.php | 7 ++++--- apps/dav/lib/CalDAV/Activity/Provider/Todo.php | 7 ++++--- apps/dav/lib/CardDAV/Activity/Provider/Addressbook.php | 7 ++++--- apps/dav/lib/CardDAV/Activity/Provider/Card.php | 7 ++++--- apps/files/lib/Activity/FavoriteProvider.php | 5 +++-- apps/files/lib/Activity/Provider.php | 5 +++-- apps/files_sharing/lib/Activity/Providers/Base.php | 5 +++-- apps/settings/lib/Activity/GroupProvider.php | 6 +++--- apps/settings/lib/Activity/Provider.php | 7 ++++--- apps/settings/lib/Activity/SecurityProvider.php | 6 +++--- apps/sharebymail/lib/Activity.php | 5 +++-- apps/systemtags/lib/Activity/Provider.php | 5 +++-- apps/twofactor_backupcodes/lib/Activity/Provider.php | 6 +++--- 15 files changed, 53 insertions(+), 41 deletions(-) diff --git a/apps/comments/lib/Activity/Provider.php b/apps/comments/lib/Activity/Provider.php index e537070a55296..4fb0c8d58beb8 100644 --- a/apps/comments/lib/Activity/Provider.php +++ b/apps/comments/lib/Activity/Provider.php @@ -5,6 +5,7 @@ */ namespace OCA\Comments\Activity; +use OCP\Activity\Exceptions\UnknownActivityException; use OCP\Activity\IEvent; use OCP\Activity\IManager; use OCP\Activity\IProvider; @@ -32,12 +33,12 @@ public function __construct( * @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() !== 'comments') { - throw new \InvalidArgumentException(); + throw new UnknownActivityException(); } $this->l = $this->languageFactory->get('comments', $language); @@ -59,9 +60,9 @@ public function parse($language, IEvent $event, ?IEvent $previousEvent = null): } return $this->parseLongVersion($event); - } else { - throw new \InvalidArgumentException(); } + throw new UnknownActivityException(); + } /** diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php b/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php index a7509831f2966..25d3260c7a60e 100644 --- a/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php +++ b/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php @@ -5,6 +5,7 @@ */ namespace OCA\DAV\CalDAV\Activity\Provider; +use OCP\Activity\Exceptions\UnknownActivityException; use OCP\Activity\IEvent; use OCP\Activity\IEventMerger; use OCP\Activity\IManager; @@ -59,12 +60,12 @@ public function __construct(IFactory $languageFactory, IURLGenerator $url, IMana * @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) { if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar') { - throw new \InvalidArgumentException(); + throw new UnknownActivityException(); } $this->l = $this->languageFactory->get('dav', $language); @@ -122,7 +123,7 @@ public function parse($language, IEvent $event, ?IEvent $previousEvent = null) { } elseif ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP . '_by') { $subject = $this->l->t('{actor} unshared calendar {calendar} from group {group}'); } else { - throw new \InvalidArgumentException(); + throw new UnknownActivityException(); } $parsedParameters = $this->getParameters($event); diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Event.php b/apps/dav/lib/CalDAV/Activity/Provider/Event.php index 959c0a815dd74..26bf69aecdd78 100644 --- a/apps/dav/lib/CalDAV/Activity/Provider/Event.php +++ b/apps/dav/lib/CalDAV/Activity/Provider/Event.php @@ -6,6 +6,7 @@ namespace OCA\DAV\CalDAV\Activity\Provider; use OC_App; +use OCP\Activity\Exceptions\UnknownActivityException; use OCP\Activity\IEvent; use OCP\Activity\IEventMerger; use OCP\Activity\IManager; @@ -106,12 +107,12 @@ protected function generateObjectParameter(array $eventData, string $affectedUse * @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) { if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar_event') { - throw new \InvalidArgumentException(); + throw new UnknownActivityException(); } $this->l = $this->languageFactory->get('dav', $language); @@ -147,7 +148,7 @@ public function parse($language, IEvent $event, ?IEvent $previousEvent = null) { } elseif ($event->getSubject() === self::SUBJECT_OBJECT_RESTORE . '_event_self') { $subject = $this->l->t('You restored event {event} of calendar {calendar}'); } else { - throw new \InvalidArgumentException(); + throw new UnknownActivityException(); } $parsedParameters = $this->getParameters($event); diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Todo.php b/apps/dav/lib/CalDAV/Activity/Provider/Todo.php index 68a95341ff24b..1e817663439ba 100644 --- a/apps/dav/lib/CalDAV/Activity/Provider/Todo.php +++ b/apps/dav/lib/CalDAV/Activity/Provider/Todo.php @@ -5,6 +5,7 @@ */ namespace OCA\DAV\CalDAV\Activity\Provider; +use OCP\Activity\Exceptions\UnknownActivityException; use OCP\Activity\IEvent; class Todo extends Event { @@ -14,12 +15,12 @@ class Todo extends Event { * @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) { if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar_todo') { - throw new \InvalidArgumentException(); + throw new UnknownActivityException(); } $this->l = $this->languageFactory->get('dav', $language); @@ -55,7 +56,7 @@ public function parse($language, IEvent $event, ?IEvent $previousEvent = null) { } elseif ($event->getSubject() === self::SUBJECT_OBJECT_MOVE . '_todo_self') { $subject = $this->l->t('You moved to-do {todo} from list {sourceCalendar} to list {targetCalendar}'); } else { - throw new \InvalidArgumentException(); + throw new UnknownActivityException(); } $parsedParameters = $this->getParameters($event); diff --git a/apps/dav/lib/CardDAV/Activity/Provider/Addressbook.php b/apps/dav/lib/CardDAV/Activity/Provider/Addressbook.php index 189c6a8e9eda8..31f26554d674a 100644 --- a/apps/dav/lib/CardDAV/Activity/Provider/Addressbook.php +++ b/apps/dav/lib/CardDAV/Activity/Provider/Addressbook.php @@ -8,6 +8,7 @@ */ namespace OCA\DAV\CardDAV\Activity\Provider; +use OCP\Activity\Exceptions\UnknownActivityException; use OCP\Activity\IEvent; use OCP\Activity\IEventMerger; use OCP\Activity\IManager; @@ -52,11 +53,11 @@ public function __construct(IFactory $languageFactory, * @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); @@ -102,7 +103,7 @@ public function parse($language, IEvent $event, ?IEvent $previousEvent = null): } 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/Card.php b/apps/dav/lib/CardDAV/Activity/Provider/Card.php index 7e8bf9b0d4d68..aa821f592d9ce 100644 --- a/apps/dav/lib/CardDAV/Activity/Provider/Card.php +++ b/apps/dav/lib/CardDAV/Activity/Provider/Card.php @@ -8,6 +8,7 @@ */ namespace OCA\DAV\CardDAV\Activity\Provider; +use OCP\Activity\Exceptions\UnknownActivityException; use OCP\Activity\IEvent; use OCP\Activity\IEventMerger; use OCP\Activity\IManager; @@ -54,11 +55,11 @@ public function __construct(IFactory $languageFactory, * @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); @@ -82,7 +83,7 @@ public function parse($language, IEvent $event, ?IEvent $previousEvent = null): } 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/files/lib/Activity/FavoriteProvider.php b/apps/files/lib/Activity/FavoriteProvider.php index 00f1387df94fa..8cfc1a8379881 100644 --- a/apps/files/lib/Activity/FavoriteProvider.php +++ b/apps/files/lib/Activity/FavoriteProvider.php @@ -5,6 +5,7 @@ */ namespace OCA\Files\Activity; +use OCP\Activity\Exceptions\UnknownActivityException; use OCP\Activity\IEvent; use OCP\Activity\IEventMerger; use OCP\Activity\IManager; @@ -50,12 +51,12 @@ public function __construct(IFactory $languageFactory, IURLGenerator $url, IMana * @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) { if ($event->getApp() !== 'files' || $event->getType() !== 'favorite') { - throw new \InvalidArgumentException(); + throw new UnknownActivityException(); } $this->l = $this->languageFactory->get('files', $language); diff --git a/apps/files/lib/Activity/Provider.php b/apps/files/lib/Activity/Provider.php index aa3ef062a162e..f777d11c02ed4 100644 --- a/apps/files/lib/Activity/Provider.php +++ b/apps/files/lib/Activity/Provider.php @@ -5,6 +5,7 @@ */ namespace OCA\Files\Activity; +use OCP\Activity\Exceptions\UnknownActivityException; use OCP\Activity\IEvent; use OCP\Activity\IEventMerger; use OCP\Activity\IManager; @@ -79,12 +80,12 @@ public function __construct(IFactory $languageFactory, * @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) { if ($event->getApp() !== 'files') { - throw new \InvalidArgumentException(); + throw new UnknownActivityException(); } $this->l = $this->languageFactory->get('files', $language); diff --git a/apps/files_sharing/lib/Activity/Providers/Base.php b/apps/files_sharing/lib/Activity/Providers/Base.php index 5bf63b7e2afdd..13bf3fea0e764 100644 --- a/apps/files_sharing/lib/Activity/Providers/Base.php +++ b/apps/files_sharing/lib/Activity/Providers/Base.php @@ -5,6 +5,7 @@ */ namespace OCA\Files_Sharing\Activity\Providers; +use OCP\Activity\Exceptions\UnknownActivityException; use OCP\Activity\IEvent; use OCP\Activity\IEventMerger; use OCP\Activity\IManager; @@ -65,12 +66,12 @@ public function __construct(IFactory $languageFactory, * @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) { if ($event->getApp() !== 'files_sharing') { - throw new \InvalidArgumentException(); + throw new UnknownActivityException(); } $this->l = $this->languageFactory->get('files_sharing', $language); diff --git a/apps/settings/lib/Activity/GroupProvider.php b/apps/settings/lib/Activity/GroupProvider.php index bad2c0c7a3530..fc7189c774db5 100644 --- a/apps/settings/lib/Activity/GroupProvider.php +++ b/apps/settings/lib/Activity/GroupProvider.php @@ -5,7 +5,7 @@ */ namespace OCA\Settings\Activity; -use InvalidArgumentException; +use OCP\Activity\Exceptions\UnknownActivityException; use OCP\Activity\IEvent; use OCP\Activity\IManager; use OCP\Activity\IProvider; @@ -48,7 +48,7 @@ public function __construct(L10nFactory $l10n, public function parse($language, IEvent $event, ?IEvent $previousEvent = null) { if ($event->getType() !== 'group_settings') { - throw new InvalidArgumentException(); + throw new UnknownActivityException(); } $l = $this->l10n->get('settings', $language); @@ -95,7 +95,7 @@ public function parse($language, IEvent $event, ?IEvent $previousEvent = null) { } break; default: - throw new InvalidArgumentException(); + throw new UnknownActivityException(); } $this->setSubjects($event, $subject, $parsedParameters); diff --git a/apps/settings/lib/Activity/Provider.php b/apps/settings/lib/Activity/Provider.php index ab9a8e3c85c32..8d726c8da22b1 100644 --- a/apps/settings/lib/Activity/Provider.php +++ b/apps/settings/lib/Activity/Provider.php @@ -8,6 +8,7 @@ */ namespace OCA\Settings\Activity; +use OCP\Activity\Exceptions\UnknownActivityException; use OCP\Activity\IEvent; use OCP\Activity\IManager; use OCP\Activity\IProvider; @@ -60,12 +61,12 @@ public function __construct(IFactory $languageFactory, * @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); @@ -105,7 +106,7 @@ public function parse($language, IEvent $event, ?IEvent $previousEvent = null): } 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); diff --git a/apps/settings/lib/Activity/SecurityProvider.php b/apps/settings/lib/Activity/SecurityProvider.php index a67b9cf365e39..8e2b4f8f45ac8 100644 --- a/apps/settings/lib/Activity/SecurityProvider.php +++ b/apps/settings/lib/Activity/SecurityProvider.php @@ -8,7 +8,7 @@ */ namespace OCA\Settings\Activity; -use InvalidArgumentException; +use OCP\Activity\Exceptions\UnknownActivityException; use OCP\Activity\IEvent; use OCP\Activity\IManager; use OCP\Activity\IProvider; @@ -34,7 +34,7 @@ public function __construct(L10nFactory $l10n, IURLGenerator $urlGenerator, IMan public function parse($language, IEvent $event, ?IEvent $previousEvent = null) { if ($event->getType() !== 'security') { - throw new InvalidArgumentException(); + throw new UnknownActivityException(); } $l = $this->l10n->get('settings', $language); @@ -85,7 +85,7 @@ public function parse($language, IEvent $event, ?IEvent $previousEvent = null) { } break; default: - throw new InvalidArgumentException(); + throw new UnknownActivityException(); } return $event; } diff --git a/apps/sharebymail/lib/Activity.php b/apps/sharebymail/lib/Activity.php index bee75c48264c5..be9deeb7290f3 100644 --- a/apps/sharebymail/lib/Activity.php +++ b/apps/sharebymail/lib/Activity.php @@ -5,6 +5,7 @@ */ namespace OCA\ShareByMail; +use OCP\Activity\Exceptions\UnknownActivityException; use OCP\Activity\IEvent; use OCP\Activity\IManager; use OCP\Activity\IProvider; @@ -62,12 +63,12 @@ public function __construct(IFactory $languageFactory, IURLGenerator $url, IMana * @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) { if ($event->getApp() !== 'sharebymail') { - throw new \InvalidArgumentException(); + throw new UnknownActivityException(); } $this->l = $this->languageFactory->get('sharebymail', $language); diff --git a/apps/systemtags/lib/Activity/Provider.php b/apps/systemtags/lib/Activity/Provider.php index b3685990ffd78..ba24dff31a875 100644 --- a/apps/systemtags/lib/Activity/Provider.php +++ b/apps/systemtags/lib/Activity/Provider.php @@ -5,6 +5,7 @@ */ namespace OCA\SystemTags\Activity; +use OCP\Activity\Exceptions\UnknownActivityException; use OCP\Activity\IEvent; use OCP\Activity\IManager; use OCP\Activity\IProvider; @@ -54,12 +55,12 @@ public function __construct(IFactory $languageFactory, IURLGenerator $url, IMana * @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) { if ($event->getApp() !== 'systemtags') { - throw new \InvalidArgumentException(); + throw new UnknownActivityException(); } $this->l = $this->languageFactory->get('systemtags', $language); diff --git a/apps/twofactor_backupcodes/lib/Activity/Provider.php b/apps/twofactor_backupcodes/lib/Activity/Provider.php index 567d2c4995cd7..7bf0db04e77b8 100644 --- a/apps/twofactor_backupcodes/lib/Activity/Provider.php +++ b/apps/twofactor_backupcodes/lib/Activity/Provider.php @@ -8,7 +8,7 @@ */ namespace OCA\TwoFactorBackupCodes\Activity; -use InvalidArgumentException; +use OCP\Activity\Exceptions\UnknownActivityException; use OCP\Activity\IEvent; use OCP\Activity\IManager; use OCP\Activity\IProvider; @@ -39,7 +39,7 @@ public function __construct(L10nFactory $l10n, IURLGenerator $urlGenerator, IMan public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent { if ($event->getApp() !== 'twofactor_backupcodes') { - throw new InvalidArgumentException(); + throw new UnknownActivityException(); } $l = $this->l10n->get('twofactor_backupcodes', $language); @@ -55,7 +55,7 @@ public function parse($language, IEvent $event, ?IEvent $previousEvent = null): } break; default: - throw new InvalidArgumentException(); + throw new UnknownActivityException(); } return $event; }