kopia lustrzana https://github.com/nextcloud/social
removing deprecated event
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/1865/head
rodzic
fbdd4d7530
commit
a99b35f745
|
@ -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>
|
||||
|
|
|
@ -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,9 +65,9 @@ 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 {
|
||||
|
@ -76,16 +75,4 @@ class Application extends App implements IBootstrap {
|
|||
->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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
public function __construct(
|
||||
AccountService $accountService
|
||||
) {
|
||||
$this->accountService = $accountService;
|
||||
}
|
||||
use OCP\Accounts\UserUpdatedEvent;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* @param IUser $user
|
||||
*
|
||||
* @return void
|
||||
* @throws SocialAppConfigException
|
||||
* @throws UrlCloudException
|
||||
* @template-implements IEventListener<\OCP\EventDispatcher\Event>
|
||||
*/
|
||||
public function userAccountUpdated(IUser $user): void {
|
||||
class UserAccountListener implements IEventListener {
|
||||
public function __construct(
|
||||
private AccountService $accountService,
|
||||
private LoggerInterface $logger
|
||||
) {
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue