diff options
Diffstat (limited to 'apps/dav/appinfo')
-rw-r--r-- | apps/dav/appinfo/app.php | 15 | ||||
-rw-r--r-- | apps/dav/appinfo/application.php | 3 |
2 files changed, 17 insertions, 1 deletions
diff --git a/apps/dav/appinfo/app.php b/apps/dav/appinfo/app.php index d33545222b0..5202e3d38b8 100644 --- a/apps/dav/appinfo/app.php +++ b/apps/dav/appinfo/app.php @@ -20,6 +20,7 @@ */ use OCA\Dav\AppInfo\Application; +use Symfony\Component\EventDispatcher\GenericEvent; $app = new Application(); $app->registerHooks(); @@ -28,6 +29,20 @@ $app->registerHooks(); return $app->getSyncService(); }); +$eventDispatcher = \OC::$server->getEventDispatcher(); + +$eventDispatcher->addListener('OCP\Federation\TrustedServerEvent::remove', + function(GenericEvent $event) use ($app) { + /** @var \OCA\DAV\CardDAV\CardDavBackend $cardDavBackend */ + $cardDavBackend = $app->getContainer()->query('CardDavBackend'); + $addressBookUri = $event->getSubject(); + $addressBook = $cardDavBackend->getAddressBooksByUri('principals/system/system', $addressBookUri); + if (!is_null($addressBook)) { + $cardDavBackend->deleteAddressBook($addressBook['id']); + } + } +); + $cm = \OC::$server->getContactsManager(); $cm->register(function() use ($cm, $app) { $userId = \OC::$server->getUserSession()->getUser()->getUID(); diff --git a/apps/dav/appinfo/application.php b/apps/dav/appinfo/application.php index 7a201e1dd78..ea9e1ad8f7c 100644 --- a/apps/dav/appinfo/application.php +++ b/apps/dav/appinfo/application.php @@ -69,7 +69,8 @@ class Application extends App { /** @var IAppContainer $c */ return new SyncService( $c->query('CardDavBackend'), - $c->getServer()->getUserManager() + $c->getServer()->getUserManager(), + $c->getServer()->getLogger() ); }); |