diff --git a/appinfo/info.xml b/appinfo/info.xml
index ba05010d..17090074 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -35,7 +35,7 @@
pgsql
sqlite
mysql
-
+
@@ -77,4 +77,4 @@
OCA\Social\Providers\ContactsMenuProvider
-
\ No newline at end of file
+
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index 764212df..024fca58 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -32,18 +32,17 @@ declare(strict_types=1);
namespace OCA\Social\AppInfo;
use OCA\Social\Dashboard\SocialWidget;
-use OCA\Social\Listeners\DeprecatedListener;
use OCA\Social\Listeners\ProfileSectionListener;
+use OCA\Social\Listeners\UserAccountListener;
use OCA\Social\Notification\Notifier;
use OCA\Social\Search\UnifiedSearchProvider;
use OCA\Social\WellKnown\WebfingerHandler;
+use OCP\Accounts\UserUpdatedEvent;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
-use OCP\IUser;
use OCP\Profile\BeforeTemplateRenderedEvent;
-use Symfony\Component\EventDispatcher\GenericEvent;
require_once __DIR__ . '/../../vendor/autoload.php';
@@ -66,26 +65,14 @@ class Application extends App implements IBootstrap {
$context->registerSearchProvider(UnifiedSearchProvider::class);
$context->registerWellKnownHandler(WebfingerHandler::class);
$context->registerEventListener(BeforeTemplateRenderedEvent::class, ProfileSectionListener::class);
- $context->registerDashboardWidget(SocialWidget::class);
+ $context->registerEventListener(UserUpdatedEvent::class, UserAccountListener::class);
- $this->registerDeprecatedListener();
+ $context->registerDashboardWidget(SocialWidget::class);
}
public function boot(IBootContext $context): void {
$manager = $context->getServerContainer()
- ->getNotificationManager();
+ ->getNotificationManager();
$manager->registerNotifierService(Notifier::class);
}
-
-
- public function registerDeprecatedListener(): void {
- $dispatcher = \OC::$server->getEventDispatcher();
- $dispatcher->addListener('OC\AccountManager::userUpdated', function (GenericEvent $event) {
- /** @var IUser $user */
- $user = $event->getSubject();
- /** @var DeprecatedListener $deprecatedListener */
- $deprecatedListener = \OC::$server->get(DeprecatedListener::class);
- $deprecatedListener->userAccountUpdated($user);
- });
- }
}
diff --git a/lib/Listeners/DeprecatedListener.php b/lib/Listeners/UserAccountListener.php
similarity index 67%
rename from lib/Listeners/DeprecatedListener.php
rename to lib/Listeners/UserAccountListener.php
index 435a276b..d51f4cf6 100644
--- a/lib/Listeners/DeprecatedListener.php
+++ b/lib/Listeners/UserAccountListener.php
@@ -29,32 +29,32 @@ declare(strict_types=1);
namespace OCA\Social\Listeners;
-use OCA\Social\Exceptions\ItemAlreadyExistsException;
-use OCA\Social\Exceptions\SocialAppConfigException;
-use OCA\Social\Exceptions\UrlCloudException;
use OCA\Social\Service\AccountService;
-use OCP\IUser;
-
-class DeprecatedListener {
- private AccountService $accountService;
+use OCP\Accounts\UserUpdatedEvent;
+use OCP\EventDispatcher\Event;
+use OCP\EventDispatcher\IEventListener;
+use Psr\Log\LoggerInterface;
+/**
+ * @template-implements IEventListener<\OCP\EventDispatcher\Event>
+ */
+class UserAccountListener implements IEventListener {
public function __construct(
- AccountService $accountService
+ private AccountService $accountService,
+ private LoggerInterface $logger
) {
- $this->accountService = $accountService;
}
- /**
- * @param IUser $user
- *
- * @return void
- * @throws SocialAppConfigException
- * @throws UrlCloudException
- */
- public function userAccountUpdated(IUser $user): void {
+ public function handle(Event $event): void {
+ if (!($event instanceof UserUpdatedEvent)) {
+ return;
+ }
+
+ $user = $event->getUser();
try {
$this->accountService->cacheLocalActorByUsername($user->getUID());
- } catch (ItemAlreadyExistsException $e) {
+ } catch (\Exception $e) {
+ $this->logger->warning('issue while updating user account', ['exception' => $e]);
}
}
}