summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/HookManager.php
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2021-08-13 14:19:03 +0200
committerThomas Citharel <tcit@tcit.fr>2021-08-13 14:19:03 +0200
commit57e2f2a903cad170eb9533b7dccdf4afaa93dd2f (patch)
treef92a34c62e363e7553befc394707c3f402d6e8df /apps/dav/lib/HookManager.php
parentfa56c13484afa1baf908b93ed5b6990c6a0e9ad6 (diff)
downloadnextcloud-server-57e2f2a903cad170eb9533b7dccdf4afaa93dd2f.tar.gz
nextcloud-server-57e2f2a903cad170eb9533b7dccdf4afaa93dd2f.zip
Delete calendar subscriptions as well when deleting user
Closes #28418 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'apps/dav/lib/HookManager.php')
-rw-r--r--apps/dav/lib/HookManager.php15
1 files changed, 13 insertions, 2 deletions
diff --git a/apps/dav/lib/HookManager.php b/apps/dav/lib/HookManager.php
index 03e7551e971..1287104fd10 100644
--- a/apps/dav/lib/HookManager.php
+++ b/apps/dav/lib/HookManager.php
@@ -58,6 +58,9 @@ class HookManager {
private $calendarsToDelete = [];
/** @var array */
+ private $subscriptionsToDelete = [];
+
+ /** @var array */
private $addressBooksToDelete = [];
/** @var Defaults */
@@ -116,9 +119,11 @@ class HookManager {
public function preDeleteUser($params) {
$uid = $params['uid'];
+ $userPrincipalUri = 'principals/users/' . $uid;
$this->usersToDelete[$uid] = $this->userManager->get($uid);
- $this->calendarsToDelete = $this->calDav->getUsersOwnCalendars('principals/users/' . $uid);
- $this->addressBooksToDelete = $this->cardDav->getUsersOwnAddressBooks('principals/users/' . $uid);
+ $this->calendarsToDelete = $this->calDav->getUsersOwnCalendars($userPrincipalUri);
+ $this->subscriptionsToDelete = $this->calDav->getSubscriptionsForUser($userPrincipalUri);
+ $this->addressBooksToDelete = $this->cardDav->getUsersOwnAddressBooks($userPrincipalUri);
}
public function preUnassignedUserId($uid) {
@@ -137,6 +142,12 @@ class HookManager {
true // Make sure the data doesn't go into the trashbin, a new user with the same UID would later see it otherwise
);
}
+
+ foreach ($this->subscriptionsToDelete as $subscription) {
+ $this->calDav->deleteSubscription(
+ $subscription['id'],
+ );
+ }
$this->calDav->deleteAllSharesByUser('principals/users/' . $uid);
foreach ($this->addressBooksToDelete as $addressBook) {