-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix(dav): Move DAV app to non deprecated event dispatcher #39190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f59c740
80ee81f
2bf339e
e1d4b82
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,8 +32,6 @@ | |
| */ | ||
| 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\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\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 @@ public function boot(IBootContext $context): void { | |
| } | ||
|
|
||
| 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 @@ public function registerHooks(HookManager $hm, | |
| } | ||
| }); | ||
|
|
||
| $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) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what type is the event now? can it be hinted?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still GenericEvent, but then Psalm complains because the event listener does not consume IEvent. Removing silences psalm and makes it work. The actual fix again is creating and only listening to typed events, but time.... |
||
| if ($event instanceof GenericEvent) { | ||
Check noticeCode scanning / Psalm DocblockTypeContradiction
Cannot resolve types for $event - docblock-defined type OCP\EventDispatcher\Event does not contain Symfony\Component\EventDispatcher\GenericEvent
|
||
| $user = $event->getSubject(); | ||
| /** @var SyncService $syncService */ | ||
| $syncService = $container->query(SyncService::class); | ||
Check noticeCode scanning / Psalm DeprecatedMethod
The method OCP\IContainer::query has been marked as deprecated
|
||
| $syncService->updateUser($user); | ||
| } | ||
| }); | ||
|
|
||
|
|
||
| $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateShares', function (GenericEvent $event) use ($container) { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| $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); | ||
|
Comment on lines
-262
to
-263
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could not find
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also in #35388 :) |
||
| } | ||
|
|
||
| public function registerContactsManager(IContactsManager $cm, IAppContainer $container): void { | ||
|
|
||
Check notice
Code scanning / Psalm
DeprecatedInterface