diff --git a/apps/dav/appinfo/v1/publicwebdav.php b/apps/dav/appinfo/v1/publicwebdav.php index 37fcebe605c30..ff64a205ef4c1 100644 --- a/apps/dav/appinfo/v1/publicwebdav.php +++ b/apps/dav/appinfo/v1/publicwebdav.php @@ -52,7 +52,8 @@ \OC::$server->getMountManager(), \OC::$server->getTagManager(), \OC::$server->getRequest(), - \OC::$server->getPreviewManager() + \OC::$server->getPreviewManager(), + \OC::$server->getEventDispatcher() ); $requestUri = \OC::$server->getRequest()->getRequestUri(); diff --git a/apps/dav/appinfo/v1/webdav.php b/apps/dav/appinfo/v1/webdav.php index d6dc9aa9b4545..e2de6bd818ecf 100644 --- a/apps/dav/appinfo/v1/webdav.php +++ b/apps/dav/appinfo/v1/webdav.php @@ -44,7 +44,8 @@ \OC::$server->getMountManager(), \OC::$server->getTagManager(), \OC::$server->getRequest(), - \OC::$server->getPreviewManager() + \OC::$server->getPreviewManager(), + \OC::$server->getEventDispatcher() ); // Backends diff --git a/apps/dav/lib/Connector/Sabre/ServerFactory.php b/apps/dav/lib/Connector/Sabre/ServerFactory.php index 1821638189d63..f1745dbd91a87 100644 --- a/apps/dav/lib/Connector/Sabre/ServerFactory.php +++ b/apps/dav/lib/Connector/Sabre/ServerFactory.php @@ -30,6 +30,7 @@ namespace OCA\DAV\Connector\Sabre; use OC\Files\Node\Folder; +use OCA\DAV\AppInfo\PluginManager; use OCA\DAV\Files\BrowserErrorPagePlugin; use OCP\Files\Mount\IMountManager; use OCP\IConfig; @@ -39,7 +40,9 @@ use OCP\IRequest; use OCP\ITagManager; use OCP\IUserSession; +use OCP\SabrePluginEvent; use Sabre\DAV\Auth\Plugin; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; class ServerFactory { /** @var IConfig */ @@ -58,6 +61,8 @@ class ServerFactory { private $request; /** @var IPreview */ private $previewManager; + /** @var EventDispatcherInterface */ + private $eventDispatcher; /** * @param IConfig $config @@ -77,7 +82,8 @@ public function __construct( IMountManager $mountManager, ITagManager $tagManager, IRequest $request, - IPreview $previewManager + IPreview $previewManager, + EventDispatcherInterface $eventDispatcher ) { $this->config = $config; $this->logger = $logger; @@ -87,6 +93,7 @@ public function __construct( $this->tagManager = $tagManager; $this->request = $request; $this->previewManager = $previewManager; + $this->eventDispatcher = $eventDispatcher; } /** @@ -134,7 +141,7 @@ public function createServer($baseUri, $server->on('beforeMethod', function () use ($server, $objectTree, $viewCallBack) { // ensure the skeleton is copied $userFolder = \OC::$server->getUserFolder(); - + /** @var \OC\Files\View $view */ $view = $viewCallBack($server); if ($userFolder instanceof Folder && $userFolder->getPath() === $view->getRoot()) { @@ -195,6 +202,18 @@ public function createServer($baseUri, ); } $server->addPlugin(new \OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin()); + + // Load dav plugins from apps + $event = new SabrePluginEvent($server); + $this->eventDispatcher->dispatch($event); + $pluginManager = new PluginManager( + \OC::$server, + \OC::$server->getAppManager() + ); + foreach ($pluginManager->getAppPlugins() as $appPlugin) { + $server->addPlugin($appPlugin); + } + }, 30); // priority 30: after auth (10) and acl(20), before lock(50) and handling the request return $server; } diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php index b7d88b2208e06..b921e0fea5e48 100644 --- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php +++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php @@ -67,7 +67,8 @@ protected function setUp(): void { $this->getMockBuilder(IRequest::class) ->disableOriginalConstructor() ->getMock(), - \OC::$server->getPreviewManager() + \OC::$server->getPreviewManager(), + \OC::$server->getEventDispatcher() ); }