Skip to content

Commit

Permalink
Remove HookManager and replace with UserChangeListener
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
  • Loading branch information
tcitworld committed Jan 20, 2022
1 parent b08cb6e commit 024bf6c
Show file tree
Hide file tree
Showing 8 changed files with 375 additions and 454 deletions.
3 changes: 2 additions & 1 deletion apps/dav/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
'OCA\\DAV\\Events\\CardCreatedEvent' => $baseDir . '/../lib/Events/CardCreatedEvent.php',
'OCA\\DAV\\Events\\CardDeletedEvent' => $baseDir . '/../lib/Events/CardDeletedEvent.php',
'OCA\\DAV\\Events\\CardUpdatedEvent' => $baseDir . '/../lib/Events/CardUpdatedEvent.php',
'OCA\\DAV\\Events\\SabreAddPluginEvent' => $baseDir . '/../lib/Events/SabreAddPluginEvent.php',
'OCA\\DAV\\Events\\SabrePluginAuthInitEvent' => $baseDir . '/../lib/Events/SabrePluginAuthInitEvent.php',
'OCA\\DAV\\Events\\SubscriptionCreatedEvent' => $baseDir . '/../lib/Events/SubscriptionCreatedEvent.php',
'OCA\\DAV\\Events\\SubscriptionDeletedEvent' => $baseDir . '/../lib/Events/SubscriptionDeletedEvent.php',
Expand All @@ -230,7 +231,6 @@
'OCA\\DAV\\Files\\RootCollection' => $baseDir . '/../lib/Files/RootCollection.php',
'OCA\\DAV\\Files\\Sharing\\FilesDropPlugin' => $baseDir . '/../lib/Files/Sharing/FilesDropPlugin.php',
'OCA\\DAV\\Files\\Sharing\\PublicLinkCheckPlugin' => $baseDir . '/../lib/Files/Sharing/PublicLinkCheckPlugin.php',
'OCA\\DAV\\HookManager' => $baseDir . '/../lib/HookManager.php',
'OCA\\DAV\\Listener\\ActivityUpdaterListener' => $baseDir . '/../lib/Listener/ActivityUpdaterListener.php',
'OCA\\DAV\\Listener\\AddressbookListener' => $baseDir . '/../lib/Listener/AddressbookListener.php',
'OCA\\DAV\\Listener\\BirthdayListener' => $baseDir . '/../lib/Listener/BirthdayListener.php',
Expand All @@ -244,6 +244,7 @@
'OCA\\DAV\\Listener\\ClearPhotoCacheListener' => $baseDir . '/../lib/Listener/ClearPhotoCacheListener.php',
'OCA\\DAV\\Listener\\SubscriptionCreationListener' => $baseDir . '/../lib/Listener/SubscriptionCreationListener.php',
'OCA\\DAV\\Listener\\SubscriptionDeletionListener' => $baseDir . '/../lib/Listener/SubscriptionDeletionListener.php',
'OCA\\DAV\\Listener\\UserChangeListener' => $baseDir . '/../lib/Listener/UserChangeListener.php',
'OCA\\DAV\\Migration\\BuildCalendarSearchIndex' => $baseDir . '/../lib/Migration/BuildCalendarSearchIndex.php',
'OCA\\DAV\\Migration\\BuildCalendarSearchIndexBackgroundJob' => $baseDir . '/../lib/Migration/BuildCalendarSearchIndexBackgroundJob.php',
'OCA\\DAV\\Migration\\BuildSocialSearchIndex' => $baseDir . '/../lib/Migration/BuildSocialSearchIndex.php',
Expand Down
3 changes: 2 additions & 1 deletion apps/dav/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ class ComposerStaticInitDAV
'OCA\\DAV\\Events\\CardCreatedEvent' => __DIR__ . '/..' . '/../lib/Events/CardCreatedEvent.php',
'OCA\\DAV\\Events\\CardDeletedEvent' => __DIR__ . '/..' . '/../lib/Events/CardDeletedEvent.php',
'OCA\\DAV\\Events\\CardUpdatedEvent' => __DIR__ . '/..' . '/../lib/Events/CardUpdatedEvent.php',
'OCA\\DAV\\Events\\SabreAddPluginEvent' => __DIR__ . '/..' . '/../lib/Events/SabreAddPluginEvent.php',
'OCA\\DAV\\Events\\SabrePluginAuthInitEvent' => __DIR__ . '/..' . '/../lib/Events/SabrePluginAuthInitEvent.php',
'OCA\\DAV\\Events\\SubscriptionCreatedEvent' => __DIR__ . '/..' . '/../lib/Events/SubscriptionCreatedEvent.php',
'OCA\\DAV\\Events\\SubscriptionDeletedEvent' => __DIR__ . '/..' . '/../lib/Events/SubscriptionDeletedEvent.php',
Expand All @@ -245,7 +246,6 @@ class ComposerStaticInitDAV
'OCA\\DAV\\Files\\RootCollection' => __DIR__ . '/..' . '/../lib/Files/RootCollection.php',
'OCA\\DAV\\Files\\Sharing\\FilesDropPlugin' => __DIR__ . '/..' . '/../lib/Files/Sharing/FilesDropPlugin.php',
'OCA\\DAV\\Files\\Sharing\\PublicLinkCheckPlugin' => __DIR__ . '/..' . '/../lib/Files/Sharing/PublicLinkCheckPlugin.php',
'OCA\\DAV\\HookManager' => __DIR__ . '/..' . '/../lib/HookManager.php',
'OCA\\DAV\\Listener\\ActivityUpdaterListener' => __DIR__ . '/..' . '/../lib/Listener/ActivityUpdaterListener.php',
'OCA\\DAV\\Listener\\AddressbookListener' => __DIR__ . '/..' . '/../lib/Listener/AddressbookListener.php',
'OCA\\DAV\\Listener\\BirthdayListener' => __DIR__ . '/..' . '/../lib/Listener/BirthdayListener.php',
Expand All @@ -259,6 +259,7 @@ class ComposerStaticInitDAV
'OCA\\DAV\\Listener\\ClearPhotoCacheListener' => __DIR__ . '/..' . '/../lib/Listener/ClearPhotoCacheListener.php',
'OCA\\DAV\\Listener\\SubscriptionCreationListener' => __DIR__ . '/..' . '/../lib/Listener/SubscriptionCreationListener.php',
'OCA\\DAV\\Listener\\SubscriptionDeletionListener' => __DIR__ . '/..' . '/../lib/Listener/SubscriptionDeletionListener.php',
'OCA\\DAV\\Listener\\UserChangeListener' => __DIR__ . '/..' . '/../lib/Listener/UserChangeListener.php',
'OCA\\DAV\\Migration\\BuildCalendarSearchIndex' => __DIR__ . '/..' . '/../lib/Migration/BuildCalendarSearchIndex.php',
'OCA\\DAV\\Migration\\BuildCalendarSearchIndexBackgroundJob' => __DIR__ . '/..' . '/../lib/Migration/BuildCalendarSearchIndexBackgroundJob.php',
'OCA\\DAV\\Migration\\BuildSocialSearchIndex' => __DIR__ . '/..' . '/../lib/Migration/BuildSocialSearchIndex.php',
Expand Down
4 changes: 2 additions & 2 deletions apps/dav/composer/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'e2c675724fc4ea50f1275bf0027b96f277c32578',
'reference' => 'a25928fb43d5f308719762b57ad826135d91c3f1',
'name' => '__root__',
'dev' => false,
),
Expand All @@ -16,7 +16,7 @@
'type' => 'library',
'install_path' => __DIR__ . '/../',
'aliases' => array(),
'reference' => 'e2c675724fc4ea50f1275bf0027b96f277c32578',
'reference' => 'a25928fb43d5f308719762b57ad826135d91c3f1',
'dev_requirement' => false,
),
),
Expand Down
19 changes: 14 additions & 5 deletions apps/dav/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
use OCA\DAV\Events\CardUpdatedEvent;
use OCA\DAV\Events\SubscriptionCreatedEvent;
use OCA\DAV\Events\SubscriptionDeletedEvent;
use OCA\DAV\HookManager;
use OCA\DAV\Listener\ActivityUpdaterListener;
use OCA\DAV\Listener\AddressbookListener;
use OCA\DAV\Listener\BirthdayListener;
Expand All @@ -84,6 +83,7 @@
use OCA\DAV\Listener\ClearPhotoCacheListener;
use OCA\DAV\Listener\SubscriptionCreationListener;
use OCA\DAV\Listener\SubscriptionDeletionListener;
use OCA\DAV\Listener\UserChangeListener;
use OCA\DAV\Search\ContactsSearchProvider;
use OCA\DAV\Search\EventsSearchProvider;
use OCA\DAV\Search\TasksSearchProvider;
Expand All @@ -99,6 +99,10 @@
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserSession;
use OCP\User\Events\BeforeUserDeletedEvent;
use OCP\User\Events\UserChangedEvent;
use OCP\User\Events\UserCreatedEvent;
use OCP\User\Events\UserDeletedEvent;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
Expand Down Expand Up @@ -183,6 +187,11 @@ public function register(IRegistrationContext $context): void {
$context->registerEventListener(CardDeletedEvent::class, ClearPhotoCacheListener::class);
$context->registerEventListener(CardUpdatedEvent::class, ClearPhotoCacheListener::class);

$context->registerEventListener(UserCreatedEvent::class, UserChangeListener::class);
$context->registerEventListener(BeforeUserDeletedEvent::class, UserChangeListener::class);
$context->registerEventListener(UserDeletedEvent::class, UserChangeListener::class);
$context->registerEventListener(UserChangedEvent::class, UserChangeListener::class);

$context->registerNotifierService(Notifier::class);

$context->registerCalendarProvider(CalendarProvider::class);
Expand All @@ -198,16 +207,16 @@ public function boot(IBootContext $context): void {
$context->injectFn([$this, 'registerCalendarReminders']);
}

public function registerHooks(HookManager $hm,
public function registerHooks(UserChangeListener $userChangeListener,
EventDispatcherInterface $dispatcher,
IAppContainer $container,
IServerContainer $serverContainer) {
$hm->setup();
$userChangeListener->setupLegacyHooks();

// first time login event setup
$dispatcher->addListener(IUser::class . '::firstLogin', function ($event) use ($hm) {
$dispatcher->addListener(IUser::class . '::firstLogin', function ($event) use ($userChangeListener) {
if ($event instanceof GenericEvent) {
$hm->firstLogin($event->getSubject());
$userChangeListener->firstLogin($event->getSubject());
}
});

Expand Down
195 changes: 0 additions & 195 deletions apps/dav/lib/HookManager.php

This file was deleted.

Loading

0 comments on commit 024bf6c

Please sign in to comment.