removing deprecated event

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/1865/head
Maxence Lange 2023-11-09 14:45:34 -01:00
rodzic fbdd4d7530
commit a99b35f745
3 zmienionych plików z 25 dodań i 38 usunięć

Wyświetl plik

@ -35,7 +35,7 @@
<database>pgsql</database>
<database>sqlite</database>
<database>mysql</database>
<nextcloud min-version="26" max-version="28" />
<nextcloud min-version="28" max-version="28" />
</dependencies>
<background-jobs>
@ -77,4 +77,4 @@
<contactsmenu>
<provider>OCA\Social\Providers\ContactsMenuProvider</provider>
</contactsmenu>
</info>
</info>

Wyświetl plik

@ -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);
});
}
}

Wyświetl plik

@ -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]);
}
}
}