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>pgsql</database>
|
||||||
<database>sqlite</database>
|
<database>sqlite</database>
|
||||||
<database>mysql</database>
|
<database>mysql</database>
|
||||||
<nextcloud min-version="26" max-version="28" />
|
<nextcloud min-version="28" max-version="28" />
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<background-jobs>
|
<background-jobs>
|
||||||
|
@ -77,4 +77,4 @@
|
||||||
<contactsmenu>
|
<contactsmenu>
|
||||||
<provider>OCA\Social\Providers\ContactsMenuProvider</provider>
|
<provider>OCA\Social\Providers\ContactsMenuProvider</provider>
|
||||||
</contactsmenu>
|
</contactsmenu>
|
||||||
</info>
|
</info>
|
||||||
|
|
|
@ -32,18 +32,17 @@ declare(strict_types=1);
|
||||||
namespace OCA\Social\AppInfo;
|
namespace OCA\Social\AppInfo;
|
||||||
|
|
||||||
use OCA\Social\Dashboard\SocialWidget;
|
use OCA\Social\Dashboard\SocialWidget;
|
||||||
use OCA\Social\Listeners\DeprecatedListener;
|
|
||||||
use OCA\Social\Listeners\ProfileSectionListener;
|
use OCA\Social\Listeners\ProfileSectionListener;
|
||||||
|
use OCA\Social\Listeners\UserAccountListener;
|
||||||
use OCA\Social\Notification\Notifier;
|
use OCA\Social\Notification\Notifier;
|
||||||
use OCA\Social\Search\UnifiedSearchProvider;
|
use OCA\Social\Search\UnifiedSearchProvider;
|
||||||
use OCA\Social\WellKnown\WebfingerHandler;
|
use OCA\Social\WellKnown\WebfingerHandler;
|
||||||
|
use OCP\Accounts\UserUpdatedEvent;
|
||||||
use OCP\AppFramework\App;
|
use OCP\AppFramework\App;
|
||||||
use OCP\AppFramework\Bootstrap\IBootContext;
|
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||||
use OCP\AppFramework\Bootstrap\IBootstrap;
|
use OCP\AppFramework\Bootstrap\IBootstrap;
|
||||||
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
||||||
use OCP\IUser;
|
|
||||||
use OCP\Profile\BeforeTemplateRenderedEvent;
|
use OCP\Profile\BeforeTemplateRenderedEvent;
|
||||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
|
||||||
|
|
||||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||||
|
|
||||||
|
@ -66,26 +65,14 @@ class Application extends App implements IBootstrap {
|
||||||
$context->registerSearchProvider(UnifiedSearchProvider::class);
|
$context->registerSearchProvider(UnifiedSearchProvider::class);
|
||||||
$context->registerWellKnownHandler(WebfingerHandler::class);
|
$context->registerWellKnownHandler(WebfingerHandler::class);
|
||||||
$context->registerEventListener(BeforeTemplateRenderedEvent::class, ProfileSectionListener::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 {
|
public function boot(IBootContext $context): void {
|
||||||
$manager = $context->getServerContainer()
|
$manager = $context->getServerContainer()
|
||||||
->getNotificationManager();
|
->getNotificationManager();
|
||||||
$manager->registerNotifierService(Notifier::class);
|
$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;
|
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 OCA\Social\Service\AccountService;
|
||||||
use OCP\IUser;
|
use OCP\Accounts\UserUpdatedEvent;
|
||||||
|
use OCP\EventDispatcher\Event;
|
||||||
class DeprecatedListener {
|
use OCP\EventDispatcher\IEventListener;
|
||||||
private AccountService $accountService;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template-implements IEventListener<\OCP\EventDispatcher\Event>
|
||||||
|
*/
|
||||||
|
class UserAccountListener implements IEventListener {
|
||||||
public function __construct(
|
public function __construct(
|
||||||
AccountService $accountService
|
private AccountService $accountService,
|
||||||
|
private LoggerInterface $logger
|
||||||
) {
|
) {
|
||||||
$this->accountService = $accountService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function handle(Event $event): void {
|
||||||
* @param IUser $user
|
if (!($event instanceof UserUpdatedEvent)) {
|
||||||
*
|
return;
|
||||||
* @return void
|
}
|
||||||
* @throws SocialAppConfigException
|
|
||||||
* @throws UrlCloudException
|
$user = $event->getUser();
|
||||||
*/
|
|
||||||
public function userAccountUpdated(IUser $user): void {
|
|
||||||
try {
|
try {
|
||||||
$this->accountService->cacheLocalActorByUsername($user->getUID());
|
$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