diff options
author | Thomas Citharel <tcit@tcit.fr> | 2018-08-05 21:27:15 +0200 |
---|---|---|
committer | Thomas Citharel <tcit@tcit.fr> | 2018-08-06 09:30:21 +0200 |
commit | a311798674880ba7d40c0ad1d3ae0d6b42f1d9b4 (patch) | |
tree | e8b7ee61c9425a10d51df76e6a5be683aa70b61d /apps | |
parent | ca54166e352f4e54887dd307bb10cc60308dbc6a (diff) | |
download | nextcloud-server-a311798674880ba7d40c0ad1d3ae0d6b42f1d9b4.tar.gz nextcloud-server-a311798674880ba7d40c0ad1d3ae0d6b42f1d9b4.zip |
Remove users from system addressbook when user deactivated
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/lib/CardDAV/SyncService.php | 24 | ||||
-rw-r--r-- | apps/dav/tests/unit/CardDAV/SyncServiceTest.php | 1 |
2 files changed, 15 insertions, 10 deletions
diff --git a/apps/dav/lib/CardDAV/SyncService.php b/apps/dav/lib/CardDAV/SyncService.php index ee68a4a26ec..5bd92015ad7 100644 --- a/apps/dav/lib/CardDAV/SyncService.php +++ b/apps/dav/lib/CardDAV/SyncService.php @@ -270,18 +270,22 @@ class SyncService { $cardId = "$name:$userId.vcf"; $card = $this->backend->getCard($addressBookId, $cardId); - if ($card === false) { - $vCard = $converter->createCardFromUser($user); - if ($vCard !== null) { - $this->backend->createCard($addressBookId, $cardId, $vCard->serialize()); - } - } else { - $vCard = $converter->createCardFromUser($user); - if (is_null($vCard)) { - $this->backend->deleteCard($addressBookId, $cardId); + if ($user->isEnabled()) { + if ($card === false) { + $vCard = $converter->createCardFromUser($user); + if ($vCard !== null) { + $this->backend->createCard($addressBookId, $cardId, $vCard->serialize()); + } } else { - $this->backend->updateCard($addressBookId, $cardId, $vCard->serialize()); + $vCard = $converter->createCardFromUser($user); + if (is_null($vCard)) { + $this->backend->deleteCard($addressBookId, $cardId); + } else { + $this->backend->updateCard($addressBookId, $cardId, $vCard->serialize()); + } } + } else { + $this->backend->deleteCard($addressBookId, $cardId); } } diff --git a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php index 1ca27d61ce4..fb8c2775ed2 100644 --- a/apps/dav/tests/unit/CardDAV/SyncServiceTest.php +++ b/apps/dav/tests/unit/CardDAV/SyncServiceTest.php @@ -106,6 +106,7 @@ class SyncServiceTest extends TestCase { $user->method('getUID')->willReturn('test-user'); $user->method('getCloudId')->willReturn('cloudId'); $user->method('getDisplayName')->willReturn('test-user'); + $user->method('isEnabled')->willReturn(true); $accountManager = $this->getMockBuilder(AccountManager::class)->disableOriginalConstructor()->getMock(); $accountManager->expects($this->any())->method('getUser') ->willReturn([ |