File tree Expand file tree Collapse file tree 5 files changed +50
-0
lines changed
Expand file tree Collapse file tree 5 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 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);
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 2727namespace OCA \ContactsInteraction \AppInfo ;
2828
2929use OCA \ContactsInteraction \Listeners \ContactInteractionListener ;
30+ use OCA \ContactsInteraction \Listeners \UserDeletedListener ;
3031use OCP \AppFramework \App ;
3132use OCP \AppFramework \Bootstrap \IBootContext ;
3233use OCP \AppFramework \Bootstrap \IBootstrap ;
3334use OCP \AppFramework \Bootstrap \IRegistrationContext ;
3435use OCP \Contacts \Events \ContactInteractedWithEvent ;
36+ use OCP \User \Events \UserDeletedEvent ;
3537
3638class Application extends App implements IBootstrap {
3739 public const APP_ID = 'contactsinteraction ' ;
@@ -42,6 +44,7 @@ public function __construct() {
4244
4345 public function register (IRegistrationContext $ context ): void {
4446 $ context ->registerEventListener (ContactInteractedWithEvent::class, ContactInteractionListener::class);
47+ $ context ->registerEventListener (UserDeletedEvent::class, UserDeletedListener::class);
4548 }
4649
4750 public function boot (IBootContext $ context ): void {
Original file line number Diff line number Diff line change @@ -128,4 +128,14 @@ public function cleanUp(int $olderThan): void {
128128
129129 $ delete ->executeStatement ();
130130 }
131+
132+ public function deleteByUserId (string $ uid ): void {
133+ $ qb = $ this ->db ->getQueryBuilder ();
134+
135+ $ delete = $ qb
136+ ->delete ($ this ->getTableName ())
137+ ->where ($ qb ->expr ()->eq ('actor_uid ' , $ qb ->createNamedParameter ($ uid )));
138+
139+ $ delete ->executeStatement ();
140+ }
131141}
Original file line number Diff line number Diff line change 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 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+ }
You can’t perform that action at this time.
0 commit comments