summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/AppInfo
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/lib/AppInfo')
-rw-r--r--apps/dav/lib/AppInfo/Application.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php
index 29c77cad07f..c22afa755cb 100644
--- a/apps/dav/lib/AppInfo/Application.php
+++ b/apps/dav/lib/AppInfo/Application.php
@@ -49,6 +49,7 @@ use OCA\DAV\HookManager;
use OCP\AppFramework\App;
use OCP\Calendar\IManager as ICalendarManager;
use OCP\Contacts\IManager as IContactsManager;
+use OCP\IConfig;
use OCP\IUser;
use Symfony\Component\EventDispatcher\GenericEvent;
@@ -244,6 +245,19 @@ class Application extends App {
$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', $listener);
$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', $listener);
$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', $listener);
+
+ /**
+ * In case the user has set their default calendar to this one
+ */
+ $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar', function (GenericEvent $event) {
+ /** @var IConfig $config */
+ $config = $this->getContainer()->getServer()->getConfig();
+ $principalUri = $event->getArgument('calendarData')['principaluri'];
+ if (strpos($principalUri, 'principals/users') === 0) {
+ list(, $UID) = \Sabre\Uri\split($principalUri);
+ $config->deleteUserValue($UID, 'dav', 'defaultCalendar');
+ }
+ });
}
public function getSyncService() {