diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2023-07-11 08:27:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-11 08:27:30 +0200 |
commit | 2dfd9ee3c9c249e8d9e7321cb28fed810062f32e (patch) | |
tree | 75e6a22827bc38400b05ee78ddc20232e245a79a /apps | |
parent | 428153c8ba79ec34828f9cb2ba1d2a3d89a6d8a3 (diff) | |
parent | e1d4b821116255c5e77f785ee6c80888e31649f5 (diff) | |
download | nextcloud-server-2dfd9ee3c9c249e8d9e7321cb28fed810062f32e.tar.gz nextcloud-server-2dfd9ee3c9c249e8d9e7321cb28fed810062f32e.zip |
Merge pull request #39190 from nextcloud/bugfix/noid/move-dav-app-to-non-deprecated-dispatcher
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/lib/AppInfo/Application.php | 45 | ||||
-rw-r--r-- | apps/dav/lib/CalDAV/CalDavBackend.php | 2 |
2 files changed, 16 insertions, 31 deletions
diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php index 10e1130f907..4ed68e68840 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; @@ -71,6 +69,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; @@ -105,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; @@ -215,9 +213,8 @@ class Application extends App implements IBootstrap { } public function registerHooks(HookManager $hm, - EventDispatcherInterface $dispatcher, - IAppContainer $container, - IServerContainer $serverContainer) { + IEventDispatcher $dispatcher, + IAppContainer $container) { $hm->setup(); // first time login event setup @@ -227,40 +224,28 @@ class Application extends App implements IBootstrap { } }); - $dispatcher->addListener('OC\AccountManager::userUpdated', function (GenericEvent $event) use ($container) { - $user = $event->getSubject(); - /** @var SyncService $syncService */ - $syncService = $container->query(SyncService::class); - $syncService->updateUser($user); + $dispatcher->addListener('OC\AccountManager::userUpdated', function ($event) use ($container) { + if ($event instanceof GenericEvent) { + $user = $event->getSubject(); + /** @var SyncService $syncService */ + $syncService = $container->query(SyncService::class); + $syncService->updateUser($user); + } }); - $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 }); - - $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 { 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); |