From f59c74062ac8621ec939773d2edf92cf63259e87 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 6 Jul 2023 10:52:19 +0200 Subject: fix(dav): Move DAV app to non deprecated event dispatcher Signed-off-by: Joas Schilling --- apps/dav/lib/AppInfo/Application.php | 5 +++-- apps/dav/lib/CalDAV/CalDavBackend.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'apps') diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php index 10e1130f907..fb82e8a3afe 100644 --- a/apps/dav/lib/AppInfo/Application.php +++ b/apps/dav/lib/AppInfo/Application.php @@ -71,6 +71,7 @@ use OCA\DAV\Events\CardDeletedEvent; use OCA\DAV\Events\CardUpdatedEvent; use OCA\DAV\Events\SubscriptionCreatedEvent; use OCA\DAV\Events\SubscriptionDeletedEvent; +use OCP\EventDispatcher\IEventDispatcher; use OCP\Federation\Events\TrustedServerRemovedEvent; use OCA\DAV\HookManager; use OCA\DAV\Listener\ActivityUpdaterListener; @@ -215,7 +216,7 @@ class Application extends App implements IBootstrap { } public function registerHooks(HookManager $hm, - EventDispatcherInterface $dispatcher, + IEventDispatcher $dispatcher, IAppContainer $container, IServerContainer $serverContainer) { $hm->setup(); @@ -227,7 +228,7 @@ class Application extends App implements IBootstrap { } }); - $dispatcher->addListener('OC\AccountManager::userUpdated', function (GenericEvent $event) use ($container) { + $dispatcher->addListener('OC\AccountManager::userUpdated', function ($event) use ($container) { $user = $event->getSubject(); /** @var SyncService $syncService */ $syncService = $container->query(SyncService::class); diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index c57d3a2764f..ef41301b840 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -2841,7 +2841,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $calendarId = $shareable->getResourceId(); $calendarRow = $this->getCalendarById($calendarId); if ($calendarRow === null) { - throw new \RuntimeException('Trying to update shares for innexistant calendar: ' . $calendarId); + throw new \RuntimeException('Trying to update shares for non-existing calendar: ' . $calendarId); } $oldShares = $this->getShares($calendarId); -- cgit v1.2.3 From 80ee81faa1333575aa93b0fd0321d0e5eb6c060d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 6 Jul 2023 10:52:51 +0200 Subject: fix(dav): Move listener to actually existing event The legacy event was removed in 4bb31c021e02d1076b5edc13d352e9c058e7c253 Signed-off-by: Joas Schilling --- apps/dav/lib/AppInfo/Application.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'apps') diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php index fb82e8a3afe..0cfa3efde9c 100644 --- a/apps/dav/lib/AppInfo/Application.php +++ b/apps/dav/lib/AppInfo/Application.php @@ -236,14 +236,14 @@ class Application extends App implements IBootstrap { }); - $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateShares', function (GenericEvent $event) use ($container) { + $dispatcher->addListener(CalendarShareUpdatedEvent::class, function (CalendarShareUpdatedEvent $event) use ($container) { /** @var Backend $backend */ $backend = $container->query(Backend::class); $backend->onCalendarUpdateShares( - $event->getArgument('calendarData'), - $event->getArgument('shares'), - $event->getArgument('add'), - $event->getArgument('remove') + $event->getCalendarData(), + $event->getOldShares(), + $event->getAdded(), + $event->getRemoved() ); // Here we should recalculate if reminders should be sent to new or old sharees -- cgit v1.2.3 From 2bf339e2a77f26c53e589acbcf39ffc2dfacfeba Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 6 Jul 2023 10:56:01 +0200 Subject: fix(dav): Remove listener for events that never existed anywhere Signed-off-by: Joas Schilling --- apps/dav/lib/AppInfo/Application.php | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'apps') diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php index 0cfa3efde9c..620f8d7e126 100644 --- a/apps/dav/lib/AppInfo/Application.php +++ b/apps/dav/lib/AppInfo/Application.php @@ -32,8 +32,6 @@ declare(strict_types=1); */ namespace OCA\DAV\AppInfo; -use Exception; -use OCA\DAV\BackgroundJob\UpdateCalendarResourcesRoomsBackgroundJob; use OCA\DAV\CalDAV\Activity\Backend; use OCA\DAV\CalDAV\AppCalendar\AppCalendarPlugin; use OCA\DAV\CalDAV\CalendarManager; @@ -106,7 +104,6 @@ use OCP\IServerContainer; use OCP\IUser; use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; use Throwable; use function is_null; @@ -217,8 +214,7 @@ class Application extends App implements IBootstrap { public function registerHooks(HookManager $hm, IEventDispatcher $dispatcher, - IAppContainer $container, - IServerContainer $serverContainer) { + IAppContainer $container) { $hm->setup(); // first time login event setup @@ -248,20 +244,6 @@ class Application extends App implements IBootstrap { // Here we should recalculate if reminders should be sent to new or old sharees }); - - $eventHandler = function () use ($container, $serverContainer): void { - try { - /** @var UpdateCalendarResourcesRoomsBackgroundJob $job */ - $job = $container->query(UpdateCalendarResourcesRoomsBackgroundJob::class); - $job->run([]); - $serverContainer->getJobList()->setLastRun($job); - } catch (Exception $ex) { - $serverContainer->get(LoggerInterface::class)->error($ex->getMessage(), ['exception' => $ex]); - } - }; - - $dispatcher->addListener('\OCP\Calendar\Resource\ForceRefreshEvent', $eventHandler); - $dispatcher->addListener('\OCP\Calendar\Room\ForceRefreshEvent', $eventHandler); } public function registerContactsManager(IContactsManager $cm, IAppContainer $container): void { -- cgit v1.2.3 From e1d4b821116255c5e77f785ee6c80888e31649f5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 7 Jul 2023 10:55:17 +0200 Subject: fix(CI): Fix type confusion with Psalm Signed-off-by: Joas Schilling --- apps/dav/lib/AppInfo/Application.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'apps') diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php index 620f8d7e126..4ed68e68840 100644 --- a/apps/dav/lib/AppInfo/Application.php +++ b/apps/dav/lib/AppInfo/Application.php @@ -225,10 +225,12 @@ class Application extends App implements IBootstrap { }); $dispatcher->addListener('OC\AccountManager::userUpdated', function ($event) use ($container) { - $user = $event->getSubject(); - /** @var SyncService $syncService */ - $syncService = $container->query(SyncService::class); - $syncService->updateUser($user); + if ($event instanceof GenericEvent) { + $user = $event->getSubject(); + /** @var SyncService $syncService */ + $syncService = $container->query(SyncService::class); + $syncService->updateUser($user); + } }); -- cgit v1.2.3