Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load apps dav plugins on the old webdav route #18061

Merged
merged 1 commit into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/dav/appinfo/v1/publicwebdav.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion apps/dav/appinfo/v1/webdav.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
\OC::$server->getMountManager(),
\OC::$server->getTagManager(),
\OC::$server->getRequest(),
\OC::$server->getPreviewManager()
\OC::$server->getPreviewManager(),
\OC::$server->getEventDispatcher()
);

// Backends
Expand Down
23 changes: 21 additions & 2 deletions apps/dav/lib/Connector/Sabre/ServerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */
Expand All @@ -58,6 +61,8 @@ class ServerFactory {
private $request;
/** @var IPreview */
private $previewManager;
/** @var EventDispatcherInterface */
private $eventDispatcher;

/**
* @param IConfig $config
Expand All @@ -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;
Expand All @@ -87,6 +93,7 @@ public function __construct(
$this->tagManager = $tagManager;
$this->request = $request;
$this->previewManager = $previewManager;
$this->eventDispatcher = $eventDispatcher;
}

/**
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ protected function setUp(): void {
$this->getMockBuilder(IRequest::class)
->disableOriginalConstructor()
->getMock(),
\OC::$server->getPreviewManager()
\OC::$server->getPreviewManager(),
\OC::$server->getEventDispatcher()
);
}

Expand Down