Merge pull request #18061 from nextcloud/bugfix/noid/dav-plugin-old

Load apps dav plugins on the old webdav route
This commit is contained in:
Roeland Jago Douma 2019-12-16 13:38:38 +01:00 committed by GitHub
commit 8d7baaff74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 5 deletions

View file

@ -52,7 +52,8 @@ $serverFactory = new OCA\DAV\Connector\Sabre\ServerFactory(
\OC::$server->getMountManager(),
\OC::$server->getTagManager(),
\OC::$server->getRequest(),
\OC::$server->getPreviewManager()
\OC::$server->getPreviewManager(),
\OC::$server->getEventDispatcher()
);
$requestUri = \OC::$server->getRequest()->getRequestUri();

View file

@ -44,7 +44,8 @@ $serverFactory = new \OCA\DAV\Connector\Sabre\ServerFactory(
\OC::$server->getMountManager(),
\OC::$server->getTagManager(),
\OC::$server->getRequest(),
\OC::$server->getPreviewManager()
\OC::$server->getPreviewManager(),
\OC::$server->getEventDispatcher()
);
// Backends

View file

@ -31,6 +31,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;
@ -40,7 +41,9 @@ use OCP\IPreview;
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 */
@ -59,6 +62,8 @@ class ServerFactory {
private $request;
/** @var IPreview */
private $previewManager;
/** @var EventDispatcherInterface */
private $eventDispatcher;
/**
* @param IConfig $config
@ -78,7 +83,8 @@ class ServerFactory {
IMountManager $mountManager,
ITagManager $tagManager,
IRequest $request,
IPreview $previewManager
IPreview $previewManager,
EventDispatcherInterface $eventDispatcher
) {
$this->config = $config;
$this->logger = $logger;
@ -88,6 +94,7 @@ class ServerFactory {
$this->tagManager = $tagManager;
$this->request = $request;
$this->previewManager = $previewManager;
$this->eventDispatcher = $eventDispatcher;
}
/**
@ -135,7 +142,7 @@ class ServerFactory {
$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()) {
@ -196,6 +203,18 @@ class ServerFactory {
);
}
$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;
}

View file

@ -67,7 +67,8 @@ abstract class RequestTestCase extends TestCase {
$this->getMockBuilder(IRequest::class)
->disableOriginalConstructor()
->getMock(),
\OC::$server->getPreviewManager()
\OC::$server->getPreviewManager(),
\OC::$server->getEventDispatcher()
);
}