Browse Source

fix: add missing listener

Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
pull/54807/head
SebastianKrupinski 3 months ago
committed by backportbot[bot]
parent
commit
c06c0eadc3
  1. 1
      apps/contactsinteraction/composer/composer/autoload_classmap.php
  2. 1
      apps/contactsinteraction/composer/composer/autoload_static.php
  3. 3
      apps/contactsinteraction/lib/AppInfo/Application.php
  4. 10
      apps/contactsinteraction/lib/Db/RecentContactMapper.php
  5. 35
      apps/contactsinteraction/lib/Listeners/UserDeletedListener.php

1
apps/contactsinteraction/composer/composer/autoload_classmap.php

@ -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',
);

1
apps/contactsinteraction/composer/composer/autoload_static.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',
);

3
apps/contactsinteraction/lib/AppInfo/Application.php

@ -9,11 +9,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';
@ -24,6 +26,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 {

10
apps/contactsinteraction/lib/Db/RecentContactMapper.php

@ -112,4 +112,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();
}
}

35
apps/contactsinteraction/lib/Listeners/UserDeletedListener.php

@ -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 readonly RecentContactMapper $recentContactMapper,
) {
}
#[\Override]
public function handle(Event $event): void {
if (!($event instanceof UserDeletedEvent)) {
return;
}
$this->recentContactMapper->deleteByUserId($event->getUser()->getUID());
}
}
Loading…
Cancel
Save