mirror of
https://github.com/nextcloud/server.git
synced 2026-05-26 03:04:35 -04:00
Merge pull request #54805 from nextcloud/backport/54794/stable28
[stable28] fix: add missing listener
This commit is contained in:
commit
7ec167fb9c
5 changed files with 50 additions and 0 deletions
|
|
@ -16,5 +16,6 @@ return array(
|
|||
'OCA\\ContactsInteraction\\Db\\RecentContact' => $baseDir . '/../lib/Db/RecentContact.php',
|
||||
'OCA\\ContactsInteraction\\Db\\RecentContactMapper' => $baseDir . '/../lib/Db/RecentContactMapper.php',
|
||||
'OCA\\ContactsInteraction\\Listeners\\ContactInteractionListener' => $baseDir . '/../lib/Listeners/ContactInteractionListener.php',
|
||||
'OCA\\ContactsInteraction\\Listeners\\UserDeletedListener' => $baseDir . '/../lib/Listeners/UserDeletedListener.php',
|
||||
'OCA\\ContactsInteraction\\Migration\\Version010000Date20200304152605' => $baseDir . '/../lib/Migration/Version010000Date20200304152605.php',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ class ComposerStaticInitContactsInteraction
|
|||
'OCA\\ContactsInteraction\\Db\\RecentContact' => __DIR__ . '/..' . '/../lib/Db/RecentContact.php',
|
||||
'OCA\\ContactsInteraction\\Db\\RecentContactMapper' => __DIR__ . '/..' . '/../lib/Db/RecentContactMapper.php',
|
||||
'OCA\\ContactsInteraction\\Listeners\\ContactInteractionListener' => __DIR__ . '/..' . '/../lib/Listeners/ContactInteractionListener.php',
|
||||
'OCA\\ContactsInteraction\\Listeners\\UserDeletedListener' => __DIR__ . '/..' . '/../lib/Listeners/UserDeletedListener.php',
|
||||
'OCA\\ContactsInteraction\\Migration\\Version010000Date20200304152605' => __DIR__ . '/..' . '/../lib/Migration/Version010000Date20200304152605.php',
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,11 +27,13 @@ declare(strict_types=1);
|
|||
namespace OCA\ContactsInteraction\AppInfo;
|
||||
|
||||
use OCA\ContactsInteraction\Listeners\ContactInteractionListener;
|
||||
use OCA\ContactsInteraction\Listeners\UserDeletedListener;
|
||||
use OCP\AppFramework\App;
|
||||
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||
use OCP\AppFramework\Bootstrap\IBootstrap;
|
||||
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
||||
use OCP\Contacts\Events\ContactInteractedWithEvent;
|
||||
use OCP\User\Events\UserDeletedEvent;
|
||||
|
||||
class Application extends App implements IBootstrap {
|
||||
public const APP_ID = 'contactsinteraction';
|
||||
|
|
@ -42,6 +44,7 @@ class Application extends App implements IBootstrap {
|
|||
|
||||
public function register(IRegistrationContext $context): void {
|
||||
$context->registerEventListener(ContactInteractedWithEvent::class, ContactInteractionListener::class);
|
||||
$context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class);
|
||||
}
|
||||
|
||||
public function boot(IBootContext $context): void {
|
||||
|
|
|
|||
|
|
@ -128,4 +128,14 @@ class RecentContactMapper extends QBMapper {
|
|||
|
||||
$delete->executeStatement();
|
||||
}
|
||||
|
||||
public function deleteByUserId(string $uid): void {
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
|
||||
$delete = $qb
|
||||
->delete($this->getTableName())
|
||||
->where($qb->expr()->eq('actor_uid', $qb->createNamedParameter($uid)));
|
||||
|
||||
$delete->executeStatement();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OCA\ContactsInteraction\Listeners;
|
||||
|
||||
use OCA\ContactsInteraction\Db\RecentContactMapper;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
use OCP\User\Events\UserDeletedEvent;
|
||||
|
||||
/**
|
||||
* @template-implements IEventListener<Event|UserDeletedEvent>
|
||||
*/
|
||||
class UserDeletedListener implements IEventListener {
|
||||
|
||||
public function __construct(
|
||||
private RecentContactMapper $recentContactMapper,
|
||||
) {
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function handle(Event $event): void {
|
||||
if (!($event instanceof UserDeletedEvent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->recentContactMapper->deleteByUserId($event->getUser()->getUID());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue