Skip to content

Commit ee48caf

Browse files
authored
Merge pull request #50689 from nextcloud/fix/migrate-dav-to-events
fix(dav): Migrate from hooks to user events
2 parents 6e1d9a2 + 355fef6 commit ee48caf

File tree

10 files changed

+326
-406
lines changed

10 files changed

+326
-406
lines changed

apps/dav/composer/composer/autoload_classmap.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@
284284
'OCA\\DAV\\Files\\RootCollection' => $baseDir . '/../lib/Files/RootCollection.php',
285285
'OCA\\DAV\\Files\\Sharing\\FilesDropPlugin' => $baseDir . '/../lib/Files/Sharing/FilesDropPlugin.php',
286286
'OCA\\DAV\\Files\\Sharing\\PublicLinkCheckPlugin' => $baseDir . '/../lib/Files/Sharing/PublicLinkCheckPlugin.php',
287-
'OCA\\DAV\\HookManager' => $baseDir . '/../lib/HookManager.php',
288287
'OCA\\DAV\\Listener\\ActivityUpdaterListener' => $baseDir . '/../lib/Listener/ActivityUpdaterListener.php',
289288
'OCA\\DAV\\Listener\\AddMissingIndicesListener' => $baseDir . '/../lib/Listener/AddMissingIndicesListener.php',
290289
'OCA\\DAV\\Listener\\AddressbookListener' => $baseDir . '/../lib/Listener/AddressbookListener.php',
@@ -299,6 +298,7 @@
299298
'OCA\\DAV\\Listener\\OutOfOfficeListener' => $baseDir . '/../lib/Listener/OutOfOfficeListener.php',
300299
'OCA\\DAV\\Listener\\SubscriptionListener' => $baseDir . '/../lib/Listener/SubscriptionListener.php',
301300
'OCA\\DAV\\Listener\\TrustedServerRemovedListener' => $baseDir . '/../lib/Listener/TrustedServerRemovedListener.php',
301+
'OCA\\DAV\\Listener\\UserEventsListener' => $baseDir . '/../lib/Listener/UserEventsListener.php',
302302
'OCA\\DAV\\Listener\\UserPreferenceListener' => $baseDir . '/../lib/Listener/UserPreferenceListener.php',
303303
'OCA\\DAV\\Migration\\BuildCalendarSearchIndex' => $baseDir . '/../lib/Migration/BuildCalendarSearchIndex.php',
304304
'OCA\\DAV\\Migration\\BuildCalendarSearchIndexBackgroundJob' => $baseDir . '/../lib/Migration/BuildCalendarSearchIndexBackgroundJob.php',

apps/dav/composer/composer/autoload_static.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,6 @@ class ComposerStaticInitDAV
299299
'OCA\\DAV\\Files\\RootCollection' => __DIR__ . '/..' . '/../lib/Files/RootCollection.php',
300300
'OCA\\DAV\\Files\\Sharing\\FilesDropPlugin' => __DIR__ . '/..' . '/../lib/Files/Sharing/FilesDropPlugin.php',
301301
'OCA\\DAV\\Files\\Sharing\\PublicLinkCheckPlugin' => __DIR__ . '/..' . '/../lib/Files/Sharing/PublicLinkCheckPlugin.php',
302-
'OCA\\DAV\\HookManager' => __DIR__ . '/..' . '/../lib/HookManager.php',
303302
'OCA\\DAV\\Listener\\ActivityUpdaterListener' => __DIR__ . '/..' . '/../lib/Listener/ActivityUpdaterListener.php',
304303
'OCA\\DAV\\Listener\\AddMissingIndicesListener' => __DIR__ . '/..' . '/../lib/Listener/AddMissingIndicesListener.php',
305304
'OCA\\DAV\\Listener\\AddressbookListener' => __DIR__ . '/..' . '/../lib/Listener/AddressbookListener.php',
@@ -314,6 +313,7 @@ class ComposerStaticInitDAV
314313
'OCA\\DAV\\Listener\\OutOfOfficeListener' => __DIR__ . '/..' . '/../lib/Listener/OutOfOfficeListener.php',
315314
'OCA\\DAV\\Listener\\SubscriptionListener' => __DIR__ . '/..' . '/../lib/Listener/SubscriptionListener.php',
316315
'OCA\\DAV\\Listener\\TrustedServerRemovedListener' => __DIR__ . '/..' . '/../lib/Listener/TrustedServerRemovedListener.php',
316+
'OCA\\DAV\\Listener\\UserEventsListener' => __DIR__ . '/..' . '/../lib/Listener/UserEventsListener.php',
317317
'OCA\\DAV\\Listener\\UserPreferenceListener' => __DIR__ . '/..' . '/../lib/Listener/UserPreferenceListener.php',
318318
'OCA\\DAV\\Migration\\BuildCalendarSearchIndex' => __DIR__ . '/..' . '/../lib/Migration/BuildCalendarSearchIndex.php',
319319
'OCA\\DAV\\Migration\\BuildCalendarSearchIndexBackgroundJob' => __DIR__ . '/..' . '/../lib/Migration/BuildCalendarSearchIndexBackgroundJob.php',

apps/dav/lib/AppInfo/Application.php

+21-16
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use OCA\DAV\CalDAV\Reminder\NotificationProviderManager;
2121
use OCA\DAV\CalDAV\Reminder\Notifier;
2222
use OCA\DAV\Capabilities;
23-
2423
use OCA\DAV\CardDAV\ContactsManager;
2524
use OCA\DAV\CardDAV\PhotoCache;
2625
use OCA\DAV\CardDAV\SyncService;
@@ -47,7 +46,6 @@
4746
use OCA\DAV\Events\CardUpdatedEvent;
4847
use OCA\DAV\Events\SubscriptionCreatedEvent;
4948
use OCA\DAV\Events\SubscriptionDeletedEvent;
50-
use OCA\DAV\HookManager;
5149
use OCA\DAV\Listener\ActivityUpdaterListener;
5250
use OCA\DAV\Listener\AddMissingIndicesListener;
5351
use OCA\DAV\Listener\AddressbookListener;
@@ -62,6 +60,7 @@
6260
use OCA\DAV\Listener\OutOfOfficeListener;
6361
use OCA\DAV\Listener\SubscriptionListener;
6462
use OCA\DAV\Listener\TrustedServerRemovedListener;
63+
use OCA\DAV\Listener\UserEventsListener;
6564
use OCA\DAV\Listener\UserPreferenceListener;
6665
use OCA\DAV\Search\ContactsSearchProvider;
6766
use OCA\DAV\Search\EventsSearchProvider;
@@ -81,15 +80,21 @@
8180
use OCP\Config\BeforePreferenceSetEvent;
8281
use OCP\Contacts\IManager as IContactsManager;
8382
use OCP\DB\Events\AddMissingIndicesEvent;
84-
use OCP\EventDispatcher\GenericEvent;
8583
use OCP\EventDispatcher\IEventDispatcher;
8684
use OCP\Federation\Events\TrustedServerRemovedEvent;
8785
use OCP\Files\AppData\IAppDataFactory;
88-
use OCP\IUser;
8986
use OCP\Server;
87+
use OCP\User\Events\BeforeUserDeletedEvent;
88+
use OCP\User\Events\BeforeUserIdUnassignedEvent;
9089
use OCP\User\Events\OutOfOfficeChangedEvent;
9190
use OCP\User\Events\OutOfOfficeClearedEvent;
9291
use OCP\User\Events\OutOfOfficeScheduledEvent;
92+
use OCP\User\Events\UserChangedEvent;
93+
use OCP\User\Events\UserCreatedEvent;
94+
use OCP\User\Events\UserDeletedEvent;
95+
use OCP\User\Events\UserFirstTimeLoggedInEvent;
96+
use OCP\User\Events\UserIdAssignedEvent;
97+
use OCP\User\Events\UserIdUnassignedEvent;
9398
use Psr\Container\ContainerInterface;
9499
use Psr\Log\LoggerInterface;
95100
use Throwable;
@@ -187,6 +192,15 @@ public function register(IRegistrationContext $context): void {
187192
$context->registerEventListener(OutOfOfficeClearedEvent::class, OutOfOfficeListener::class);
188193
$context->registerEventListener(OutOfOfficeScheduledEvent::class, OutOfOfficeListener::class);
189194

195+
$context->registerEventListener(UserFirstTimeLoggedInEvent::class, UserEventsListener::class);
196+
$context->registerEventListener(UserIdAssignedEvent::class, UserEventsListener::class);
197+
$context->registerEventListener(BeforeUserIdUnassignedEvent::class, UserEventsListener::class);
198+
$context->registerEventListener(UserIdUnassignedEvent::class, UserEventsListener::class);
199+
$context->registerEventListener(BeforeUserDeletedEvent::class, UserEventsListener::class);
200+
$context->registerEventListener(UserDeletedEvent::class, UserEventsListener::class);
201+
$context->registerEventListener(UserCreatedEvent::class, UserEventsListener::class);
202+
$context->registerEventListener(UserChangedEvent::class, UserEventsListener::class);
203+
190204
$context->registerNotifierService(Notifier::class);
191205

192206
$context->registerCalendarProvider(CalendarProvider::class);
@@ -209,18 +223,10 @@ public function boot(IBootContext $context): void {
209223
$context->injectFn([$this, 'registerCalendarReminders']);
210224
}
211225

212-
public function registerHooks(HookManager $hm,
226+
public function registerHooks(
213227
IEventDispatcher $dispatcher,
214-
IAppContainer $container) {
215-
$hm->setup();
216-
217-
// first time login event setup
218-
$dispatcher->addListener(IUser::class . '::firstLogin', function ($event) use ($hm): void {
219-
if ($event instanceof GenericEvent) {
220-
$hm->firstLogin($event->getSubject());
221-
}
222-
});
223-
228+
IAppContainer $container,
229+
): void {
224230
$dispatcher->addListener(UserUpdatedEvent::class, function (UserUpdatedEvent $event) use ($container): void {
225231
/** @var SyncService $syncService */
226232
$syncService = Server::get(SyncService::class);
@@ -240,7 +246,6 @@ public function registerHooks(HookManager $hm,
240246

241247
// Here we should recalculate if reminders should be sent to new or old sharees
242248
});
243-
244249
}
245250

246251
public function registerContactsManager(IContactsManager $cm, IAppContainer $container): void {

apps/dav/lib/HookManager.php

-155
This file was deleted.

0 commit comments

Comments
 (0)