Skip to content

Commit c06c0ea

Browse files
fix: add missing listener
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com> Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
1 parent 5eada83 commit c06c0ea

File tree

5 files changed

+50
-0
lines changed

5 files changed

+50
-0
lines changed

apps/contactsinteraction/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
'OCA\\ContactsInteraction\\Db\\RecentContact' => $baseDir . '/../lib/Db/RecentContact.php',
1717
'OCA\\ContactsInteraction\\Db\\RecentContactMapper' => $baseDir . '/../lib/Db/RecentContactMapper.php',
1818
'OCA\\ContactsInteraction\\Listeners\\ContactInteractionListener' => $baseDir . '/../lib/Listeners/ContactInteractionListener.php',
19+
'OCA\\ContactsInteraction\\Listeners\\UserDeletedListener' => $baseDir . '/../lib/Listeners/UserDeletedListener.php',
1920
'OCA\\ContactsInteraction\\Migration\\Version010000Date20200304152605' => $baseDir . '/../lib/Migration/Version010000Date20200304152605.php',
2021
);

apps/contactsinteraction/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class ComposerStaticInitContactsInteraction
3131
'OCA\\ContactsInteraction\\Db\\RecentContact' => __DIR__ . '/..' . '/../lib/Db/RecentContact.php',
3232
'OCA\\ContactsInteraction\\Db\\RecentContactMapper' => __DIR__ . '/..' . '/../lib/Db/RecentContactMapper.php',
3333
'OCA\\ContactsInteraction\\Listeners\\ContactInteractionListener' => __DIR__ . '/..' . '/../lib/Listeners/ContactInteractionListener.php',
34+
'OCA\\ContactsInteraction\\Listeners\\UserDeletedListener' => __DIR__ . '/..' . '/../lib/Listeners/UserDeletedListener.php',
3435
'OCA\\ContactsInteraction\\Migration\\Version010000Date20200304152605' => __DIR__ . '/..' . '/../lib/Migration/Version010000Date20200304152605.php',
3536
);
3637

apps/contactsinteraction/lib/AppInfo/Application.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
namespace OCA\ContactsInteraction\AppInfo;
1010

1111
use OCA\ContactsInteraction\Listeners\ContactInteractionListener;
12+
use OCA\ContactsInteraction\Listeners\UserDeletedListener;
1213
use OCP\AppFramework\App;
1314
use OCP\AppFramework\Bootstrap\IBootContext;
1415
use OCP\AppFramework\Bootstrap\IBootstrap;
1516
use OCP\AppFramework\Bootstrap\IRegistrationContext;
1617
use OCP\Contacts\Events\ContactInteractedWithEvent;
18+
use OCP\User\Events\UserDeletedEvent;
1719

1820
class Application extends App implements IBootstrap {
1921
public const APP_ID = 'contactsinteraction';
@@ -24,6 +26,7 @@ public function __construct() {
2426

2527
public function register(IRegistrationContext $context): void {
2628
$context->registerEventListener(ContactInteractedWithEvent::class, ContactInteractionListener::class);
29+
$context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class);
2730
}
2831

2932
public function boot(IBootContext $context): void {

apps/contactsinteraction/lib/Db/RecentContactMapper.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,14 @@ public function cleanUp(int $olderThan): void {
112112

113113
$delete->executeStatement();
114114
}
115+
116+
public function deleteByUserId(string $uid): void {
117+
$qb = $this->db->getQueryBuilder();
118+
119+
$delete = $qb
120+
->delete($this->getTableName())
121+
->where($qb->expr()->eq('actor_uid', $qb->createNamedParameter($uid)));
122+
123+
$delete->executeStatement();
124+
}
115125
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace OCA\ContactsInteraction\Listeners;
11+
12+
use OCA\ContactsInteraction\Db\RecentContactMapper;
13+
use OCP\EventDispatcher\Event;
14+
use OCP\EventDispatcher\IEventListener;
15+
use OCP\User\Events\UserDeletedEvent;
16+
17+
/**
18+
* @template-implements IEventListener<Event|UserDeletedEvent>
19+
*/
20+
class UserDeletedListener implements IEventListener {
21+
22+
public function __construct(
23+
private readonly RecentContactMapper $recentContactMapper,
24+
) {
25+
}
26+
27+
#[\Override]
28+
public function handle(Event $event): void {
29+
if (!($event instanceof UserDeletedEvent)) {
30+
return;
31+
}
32+
33+
$this->recentContactMapper->deleteByUserId($event->getUser()->getUID());
34+
}
35+
}

0 commit comments

Comments
 (0)