Skip to content

Commit

Permalink
Fix removed symfony dispatcher
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Oct 26, 2023
1 parent d524624 commit f9f67ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ This product includes GeoLite2 data created by MaxMind, available from [maxmind.
<screenshot>https://github.com/nextcloud/terms_of_service/raw/master/docs/notification-and-settings.png</screenshot>

<dependencies>
<nextcloud min-version="26" max-version="28" />
<nextcloud min-version="28" max-version="28" />
</dependencies>

<repair-steps>
Expand Down
15 changes: 4 additions & 11 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
use OCA\TermsOfService\Listener\RegistrationIntegration;
use OCA\TermsOfService\Listener\UserDeletedListener;
use OCA\TermsOfService\Notifications\Notifier;
use OCA\TermsOfService\Dav\CheckPlugin;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
Expand All @@ -44,13 +43,11 @@
use OCP\IUser;
use OCP\IUserSession;
use OCP\Notification\IManager;
use OCP\SabrePluginEvent;
use OCP\User\Events\UserDeletedEvent;
use OCP\User\Events\UserFirstTimeLoggedInEvent;
use OCP\Util;
use Psr\Log\LoggerInterface;
use Psr\Container\ContainerExceptionInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;

include_once __DIR__ . '/../../vendor/autoload.php';

Expand Down Expand Up @@ -145,13 +142,9 @@ public function registerNotifier(IManager $notificationManager): void {
$notificationManager->registerNotifierService(Notifier::class);
}

public function createNotificationOnFirstLogin(IManager $notificationManager, EventDispatcherInterface $dispatcher): void {
$dispatcher->addListener(IUser::class . '::firstLogin', function(GenericEvent $event) use ($notificationManager) {
$user = $event->getSubject();
if (!$user instanceof IUser) {
return;
}

public function createNotificationOnFirstLogin(IManager $notificationManager, IEventDispatcher $dispatcher): void {
$dispatcher->addListener(UserFirstTimeLoggedInEvent::class, function(UserFirstTimeLoggedInEvent $event) use ($notificationManager) {
$user = $event->getUser();
$notification = $notificationManager->createNotification();
$notification->setApp('terms_of_service')
->setDateTime(new \DateTime())
Expand Down

0 comments on commit f9f67ed

Please sign in to comment.