diff options
Diffstat (limited to 'apps/dav/lib/AppInfo/Application.php')
-rw-r--r-- | apps/dav/lib/AppInfo/Application.php | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php index b4f16f3cadf..5d89324d4a9 100644 --- a/apps/dav/lib/AppInfo/Application.php +++ b/apps/dav/lib/AppInfo/Application.php @@ -24,11 +24,13 @@ */ namespace OCA\DAV\AppInfo; +use OC\AppFramework\Utility\SimpleContainer; use OCA\DAV\CalDAV\Activity\Backend; use OCA\DAV\CalDAV\Activity\Provider\Event; use OCA\DAV\CalDAV\BirthdayService; use OCA\DAV\Capabilities; use OCA\DAV\CardDAV\ContactsManager; +use OCA\DAV\CardDAV\PhotoCache; use OCA\DAV\CardDAV\SyncService; use OCA\DAV\HookManager; use \OCP\AppFramework\App; @@ -44,10 +46,19 @@ class Application extends App { public function __construct() { parent::__construct('dav'); + $container = $this->getContainer(); + $server = $container->getServer(); + + $container->registerService(PhotoCache::class, function(SimpleContainer $s) use ($server) { + return new PhotoCache( + $server->getAppDataDir('dav-photocache') + ); + }); + /* * Register capabilities */ - $this->getContainer()->registerCapability(Capabilities::class); + $container->registerCapability(Capabilities::class); } /** @@ -101,6 +112,19 @@ class Application extends App { } }); + $clearPhotoCache = function($event) { + if ($event instanceof GenericEvent) { + /** @var PhotoCache $p */ + $p = $this->getContainer()->query(PhotoCache::class); + $p->delete( + $event->getArgument('addressBookId'), + $event->getArgument('cardUri') + ); + } + }; + $dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::updateCard', $clearPhotoCache); + $dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::deleteCard', $clearPhotoCache); + $dispatcher->addListener('OC\AccountManager::userUpdated', function(GenericEvent $event) { $user = $event->getSubject(); $syncService = $this->getContainer()->query(SyncService::class); |