summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-04-23 09:50:13 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-05-30 13:27:51 +0200
commited0069b8e6d9bcf75b3b35e72b3c0b2b542b0268 (patch)
tree93b56aa9b502d04bbca5306d0e1b06413ff03230 /apps/dav/lib
parent4c1f88efb16564798efbce62153a7eebc174a640 (diff)
downloadnextcloud-server-ed0069b8e6d9bcf75b3b35e72b3c0b2b542b0268.tar.gz
nextcloud-server-ed0069b8e6d9bcf75b3b35e72b3c0b2b542b0268.zip
Do not load calendar/addressbook plugins if not needed
Fixes #6711 Based on https://github.com/owncloud/core/pull/30149/commits/f0fb21cf3563088284c56be4eac48c7d9725cb21 Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/Server.php44
1 files changed, 28 insertions, 16 deletions
diff --git a/apps/dav/lib/Server.php b/apps/dav/lib/Server.php
index a34ba94f21f..5a4b1d1dcf5 100644
--- a/apps/dav/lib/Server.php
+++ b/apps/dav/lib/Server.php
@@ -80,7 +80,6 @@ class Server {
$this->baseUri = $baseUri;
$logger = \OC::$server->getLogger();
$dispatcher = \OC::$server->getEventDispatcher();
- $sendInvitations = \OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes';
$root = new RootCollection();
$this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root));
@@ -139,24 +138,28 @@ class Server {
$this->server->addPlugin($acl);
// calendar plugins
- $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin());
- $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
- $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin());
- if ($sendInvitations) {
- $this->server->addPlugin(\OC::$server->query(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class));
+ if ($this->requestIsForSubtree('calendars')) {
+ $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin());
+ $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
+ $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin());
+ if (\OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes') {
+ $this->server->addPlugin(\OC::$server->query(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class));
+ }
+ $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
+ $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
+ $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
+ $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
+ \OC::$server->getConfig(),
+ \OC::$server->getURLGenerator()
+ ));
}
- $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
- $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
- $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
- $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
- \OC::$server->getConfig(),
- \OC::$server->getURLGenerator()
- ));
// addressbook plugins
- $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin());
- $this->server->addPlugin(new VCFExportPlugin());
- $this->server->addPlugin(new ImageExportPlugin(new PhotoCache(\OC::$server->getAppDataDir('dav-photocache'))));
+ if ($this->requestIsForSubtree('addressbooks')) {
+ $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin());
+ $this->server->addPlugin(new VCFExportPlugin());
+ $this->server->addPlugin(new ImageExportPlugin(new PhotoCache(\OC::$server->getAppDataDir('dav-photocache'))));
+ }
// system tags plugins
$this->server->addPlugin(new SystemTagPlugin(
@@ -282,4 +285,13 @@ class Server {
public function exec() {
$this->server->exec();
}
+
+ /**
+ * @param string $subTree
+ * @return bool
+ */
+ private function requestIsForSubtree($subTree) {
+ $subTree = trim($subTree, " /");
+ return strpos($this->server->getRequestUri(), "$subTree/") === 0;
+ }
}