@@ -75,270 +75,270 @@ |
||
75 | 75 | |
76 | 76 | class Server { |
77 | 77 | |
78 | - /** @var IRequest */ |
|
79 | - private $request; |
|
80 | - |
|
81 | - /** @var string */ |
|
82 | - private $baseUri; |
|
83 | - |
|
84 | - /** @var Connector\Sabre\Server */ |
|
85 | - public $server; |
|
86 | - |
|
87 | - public function __construct(IRequest $request, $baseUri) { |
|
88 | - $this->request = $request; |
|
89 | - $this->baseUri = $baseUri; |
|
90 | - $logger = \OC::$server->getLogger(); |
|
91 | - $dispatcher = \OC::$server->getEventDispatcher(); |
|
92 | - /** @var IEventDispatcher $newDispatcher */ |
|
93 | - $newDispatcher = \OC::$server->query(IEventDispatcher::class); |
|
94 | - |
|
95 | - $root = new RootCollection(); |
|
96 | - $this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root)); |
|
97 | - |
|
98 | - // Add maintenance plugin |
|
99 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig(), \OC::$server->getL10N('dav'))); |
|
100 | - |
|
101 | - // Backends |
|
102 | - $authBackend = new Auth( |
|
103 | - \OC::$server->getSession(), |
|
104 | - \OC::$server->getUserSession(), |
|
105 | - \OC::$server->getRequest(), |
|
106 | - \OC::$server->getTwoFactorAuthManager(), |
|
107 | - \OC::$server->getBruteForceThrottler() |
|
108 | - ); |
|
109 | - |
|
110 | - // Set URL explicitly due to reverse-proxy situations |
|
111 | - $this->server->httpRequest->setUrl($this->request->getRequestUri()); |
|
112 | - $this->server->setBaseUri($this->baseUri); |
|
113 | - |
|
114 | - $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig())); |
|
115 | - $this->server->addPlugin(new AnonymousOptionsPlugin()); |
|
116 | - $authPlugin = new Plugin(); |
|
117 | - $authPlugin->addBackend(new PublicAuth()); |
|
118 | - $this->server->addPlugin($authPlugin); |
|
119 | - |
|
120 | - // allow setup of additional auth backends |
|
121 | - $event = new SabrePluginEvent($this->server); |
|
122 | - $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event); |
|
123 | - |
|
124 | - $newAuthEvent = new SabrePluginAuthInitEvent($this->server); |
|
125 | - $newDispatcher->dispatchTyped($newAuthEvent); |
|
126 | - |
|
127 | - $bearerAuthBackend = new BearerAuth( |
|
128 | - \OC::$server->getUserSession(), |
|
129 | - \OC::$server->getSession(), |
|
130 | - \OC::$server->getRequest() |
|
131 | - ); |
|
132 | - $authPlugin->addBackend($bearerAuthBackend); |
|
133 | - // because we are throwing exceptions this plugin has to be the last one |
|
134 | - $authPlugin->addBackend($authBackend); |
|
135 | - |
|
136 | - // debugging |
|
137 | - if (\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
138 | - $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin()); |
|
139 | - } else { |
|
140 | - $this->server->addPlugin(new DummyGetResponsePlugin()); |
|
141 | - } |
|
142 | - |
|
143 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger)); |
|
144 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin()); |
|
145 | - $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
|
146 | - |
|
147 | - // acl |
|
148 | - $acl = new DavAclPlugin(); |
|
149 | - $acl->principalCollectionSet = [ |
|
150 | - 'principals/users', |
|
151 | - 'principals/groups', |
|
152 | - 'principals/calendar-resources', |
|
153 | - 'principals/calendar-rooms', |
|
154 | - ]; |
|
155 | - $acl->defaultUsernamePath = 'principals/users'; |
|
156 | - $this->server->addPlugin($acl); |
|
157 | - |
|
158 | - // calendar plugins |
|
159 | - if ($this->requestIsForSubtree(['calendars', 'public-calendars', 'system-calendars', 'principals'])) { |
|
160 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin()); |
|
161 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\ICSExportPlugin\ICSExportPlugin(\OC::$server->getConfig(), \OC::$server->getLogger())); |
|
162 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin(\OC::$server->getConfig())); |
|
163 | - if (\OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes') { |
|
164 | - $this->server->addPlugin(\OC::$server->query(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class)); |
|
165 | - } |
|
166 | - |
|
167 | - $this->server->addPlugin(\OC::$server->get(\OCA\DAV\CalDAV\Trashbin\Plugin::class)); |
|
168 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\WebcalCaching\Plugin($request)); |
|
169 | - $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin()); |
|
170 | - |
|
171 | - $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin()); |
|
172 | - $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest(), \OC::$server->getConfig())); |
|
173 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin( |
|
174 | - \OC::$server->getConfig(), |
|
175 | - \OC::$server->getURLGenerator() |
|
176 | - )); |
|
177 | - } |
|
178 | - |
|
179 | - // addressbook plugins |
|
180 | - if ($this->requestIsForSubtree(['addressbooks', 'principals'])) { |
|
181 | - $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest(), \OC::$server->getConfig())); |
|
182 | - $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin()); |
|
183 | - $this->server->addPlugin(new VCFExportPlugin()); |
|
184 | - $this->server->addPlugin(new MultiGetExportPlugin()); |
|
185 | - $this->server->addPlugin(new HasPhotoPlugin()); |
|
186 | - $this->server->addPlugin(new ImageExportPlugin(new PhotoCache( |
|
187 | - \OC::$server->getAppDataDir('dav-photocache'), |
|
188 | - \OC::$server->getLogger()) |
|
189 | - )); |
|
190 | - } |
|
191 | - |
|
192 | - // system tags plugins |
|
193 | - $this->server->addPlugin(new SystemTagPlugin( |
|
194 | - \OC::$server->getSystemTagManager(), |
|
195 | - \OC::$server->getGroupManager(), |
|
196 | - \OC::$server->getUserSession() |
|
197 | - )); |
|
198 | - |
|
199 | - // comments plugin |
|
200 | - $this->server->addPlugin(new CommentsPlugin( |
|
201 | - \OC::$server->getCommentsManager(), |
|
202 | - \OC::$server->getUserSession() |
|
203 | - )); |
|
204 | - |
|
205 | - $this->server->addPlugin(new CopyEtagHeaderPlugin()); |
|
206 | - $this->server->addPlugin(new ChunkingPlugin()); |
|
207 | - |
|
208 | - // allow setup of additional plugins |
|
209 | - $dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event); |
|
210 | - |
|
211 | - // Some WebDAV clients do require Class 2 WebDAV support (locking), since |
|
212 | - // we do not provide locking we emulate it using a fake locking plugin. |
|
213 | - if ($request->isUserAgent([ |
|
214 | - '/WebDAVFS/', |
|
215 | - '/OneNote/', |
|
216 | - '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
217 | - ])) { |
|
218 | - $this->server->addPlugin(new FakeLockerPlugin()); |
|
219 | - } |
|
220 | - |
|
221 | - if (BrowserErrorPagePlugin::isBrowserRequest($request)) { |
|
222 | - $this->server->addPlugin(new BrowserErrorPagePlugin()); |
|
223 | - } |
|
224 | - |
|
225 | - $lazySearchBackend = new LazySearchBackend(); |
|
226 | - $this->server->addPlugin(new SearchPlugin($lazySearchBackend)); |
|
227 | - |
|
228 | - // wait with registering these until auth is handled and the filesystem is setup |
|
229 | - $this->server->on('beforeMethod:*', function () use ($root, $lazySearchBackend) { |
|
230 | - // custom properties plugin must be the last one |
|
231 | - $userSession = \OC::$server->getUserSession(); |
|
232 | - $user = $userSession->getUser(); |
|
233 | - if ($user !== null) { |
|
234 | - $view = \OC\Files\Filesystem::getView(); |
|
235 | - $this->server->addPlugin( |
|
236 | - new FilesPlugin( |
|
237 | - $this->server->tree, |
|
238 | - \OC::$server->getConfig(), |
|
239 | - $this->request, |
|
240 | - \OC::$server->getPreviewManager(), |
|
241 | - false, |
|
242 | - !\OC::$server->getConfig()->getSystemValue('debug', false) |
|
243 | - ) |
|
244 | - ); |
|
245 | - |
|
246 | - $this->server->addPlugin( |
|
247 | - new \Sabre\DAV\PropertyStorage\Plugin( |
|
248 | - new CustomPropertiesBackend( |
|
249 | - $this->server->tree, |
|
250 | - \OC::$server->getDatabaseConnection(), |
|
251 | - \OC::$server->getUserSession()->getUser() |
|
252 | - ) |
|
253 | - ) |
|
254 | - ); |
|
255 | - if ($view !== null) { |
|
256 | - $this->server->addPlugin( |
|
257 | - new QuotaPlugin($view)); |
|
258 | - } |
|
259 | - $this->server->addPlugin( |
|
260 | - new TagsPlugin( |
|
261 | - $this->server->tree, \OC::$server->getTagManager() |
|
262 | - ) |
|
263 | - ); |
|
264 | - // TODO: switch to LazyUserFolder |
|
265 | - $userFolder = \OC::$server->getUserFolder(); |
|
266 | - $this->server->addPlugin(new SharesPlugin( |
|
267 | - $this->server->tree, |
|
268 | - $userSession, |
|
269 | - $userFolder, |
|
270 | - \OC::$server->getShareManager() |
|
271 | - )); |
|
272 | - $this->server->addPlugin(new CommentPropertiesPlugin( |
|
273 | - \OC::$server->getCommentsManager(), |
|
274 | - $userSession |
|
275 | - )); |
|
276 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin()); |
|
277 | - if ($view !== null) { |
|
278 | - $this->server->addPlugin(new FilesReportPlugin( |
|
279 | - $this->server->tree, |
|
280 | - $view, |
|
281 | - \OC::$server->getSystemTagManager(), |
|
282 | - \OC::$server->getSystemTagObjectMapper(), |
|
283 | - \OC::$server->getTagManager(), |
|
284 | - $userSession, |
|
285 | - \OC::$server->getGroupManager(), |
|
286 | - $userFolder, |
|
287 | - \OC::$server->getAppManager() |
|
288 | - )); |
|
289 | - $lazySearchBackend->setBackend(new \OCA\DAV\Files\FileSearchBackend( |
|
290 | - $this->server->tree, |
|
291 | - $user, |
|
292 | - \OC::$server->getRootFolder(), |
|
293 | - \OC::$server->getShareManager(), |
|
294 | - $view |
|
295 | - )); |
|
296 | - } |
|
297 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\BirthdayCalendar\EnablePlugin( |
|
298 | - \OC::$server->getConfig(), |
|
299 | - \OC::$server->query(BirthdayService::class) |
|
300 | - )); |
|
301 | - $this->server->addPlugin(new AppleProvisioningPlugin( |
|
302 | - \OC::$server->getUserSession(), |
|
303 | - \OC::$server->getURLGenerator(), |
|
304 | - \OC::$server->getThemingDefaults(), |
|
305 | - \OC::$server->getRequest(), |
|
306 | - \OC::$server->getL10N('dav'), |
|
307 | - function () { |
|
308 | - return UUIDUtil::getUUID(); |
|
309 | - } |
|
310 | - )); |
|
311 | - } |
|
312 | - |
|
313 | - // register plugins from apps |
|
314 | - $pluginManager = new PluginManager( |
|
315 | - \OC::$server, |
|
316 | - \OC::$server->getAppManager() |
|
317 | - ); |
|
318 | - foreach ($pluginManager->getAppPlugins() as $appPlugin) { |
|
319 | - $this->server->addPlugin($appPlugin); |
|
320 | - } |
|
321 | - foreach ($pluginManager->getAppCollections() as $appCollection) { |
|
322 | - $root->addChild($appCollection); |
|
323 | - } |
|
324 | - }); |
|
325 | - |
|
326 | - $this->server->addPlugin( |
|
327 | - new PropfindCompressionPlugin() |
|
328 | - ); |
|
329 | - } |
|
330 | - |
|
331 | - public function exec() { |
|
332 | - $this->server->exec(); |
|
333 | - } |
|
334 | - |
|
335 | - private function requestIsForSubtree(array $subTrees): bool { |
|
336 | - foreach ($subTrees as $subTree) { |
|
337 | - $subTree = trim($subTree, ' /'); |
|
338 | - if (strpos($this->server->getRequestUri(), $subTree.'/') === 0) { |
|
339 | - return true; |
|
340 | - } |
|
341 | - } |
|
342 | - return false; |
|
343 | - } |
|
78 | + /** @var IRequest */ |
|
79 | + private $request; |
|
80 | + |
|
81 | + /** @var string */ |
|
82 | + private $baseUri; |
|
83 | + |
|
84 | + /** @var Connector\Sabre\Server */ |
|
85 | + public $server; |
|
86 | + |
|
87 | + public function __construct(IRequest $request, $baseUri) { |
|
88 | + $this->request = $request; |
|
89 | + $this->baseUri = $baseUri; |
|
90 | + $logger = \OC::$server->getLogger(); |
|
91 | + $dispatcher = \OC::$server->getEventDispatcher(); |
|
92 | + /** @var IEventDispatcher $newDispatcher */ |
|
93 | + $newDispatcher = \OC::$server->query(IEventDispatcher::class); |
|
94 | + |
|
95 | + $root = new RootCollection(); |
|
96 | + $this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root)); |
|
97 | + |
|
98 | + // Add maintenance plugin |
|
99 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig(), \OC::$server->getL10N('dav'))); |
|
100 | + |
|
101 | + // Backends |
|
102 | + $authBackend = new Auth( |
|
103 | + \OC::$server->getSession(), |
|
104 | + \OC::$server->getUserSession(), |
|
105 | + \OC::$server->getRequest(), |
|
106 | + \OC::$server->getTwoFactorAuthManager(), |
|
107 | + \OC::$server->getBruteForceThrottler() |
|
108 | + ); |
|
109 | + |
|
110 | + // Set URL explicitly due to reverse-proxy situations |
|
111 | + $this->server->httpRequest->setUrl($this->request->getRequestUri()); |
|
112 | + $this->server->setBaseUri($this->baseUri); |
|
113 | + |
|
114 | + $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig())); |
|
115 | + $this->server->addPlugin(new AnonymousOptionsPlugin()); |
|
116 | + $authPlugin = new Plugin(); |
|
117 | + $authPlugin->addBackend(new PublicAuth()); |
|
118 | + $this->server->addPlugin($authPlugin); |
|
119 | + |
|
120 | + // allow setup of additional auth backends |
|
121 | + $event = new SabrePluginEvent($this->server); |
|
122 | + $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event); |
|
123 | + |
|
124 | + $newAuthEvent = new SabrePluginAuthInitEvent($this->server); |
|
125 | + $newDispatcher->dispatchTyped($newAuthEvent); |
|
126 | + |
|
127 | + $bearerAuthBackend = new BearerAuth( |
|
128 | + \OC::$server->getUserSession(), |
|
129 | + \OC::$server->getSession(), |
|
130 | + \OC::$server->getRequest() |
|
131 | + ); |
|
132 | + $authPlugin->addBackend($bearerAuthBackend); |
|
133 | + // because we are throwing exceptions this plugin has to be the last one |
|
134 | + $authPlugin->addBackend($authBackend); |
|
135 | + |
|
136 | + // debugging |
|
137 | + if (\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
138 | + $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin()); |
|
139 | + } else { |
|
140 | + $this->server->addPlugin(new DummyGetResponsePlugin()); |
|
141 | + } |
|
142 | + |
|
143 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger)); |
|
144 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin()); |
|
145 | + $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
|
146 | + |
|
147 | + // acl |
|
148 | + $acl = new DavAclPlugin(); |
|
149 | + $acl->principalCollectionSet = [ |
|
150 | + 'principals/users', |
|
151 | + 'principals/groups', |
|
152 | + 'principals/calendar-resources', |
|
153 | + 'principals/calendar-rooms', |
|
154 | + ]; |
|
155 | + $acl->defaultUsernamePath = 'principals/users'; |
|
156 | + $this->server->addPlugin($acl); |
|
157 | + |
|
158 | + // calendar plugins |
|
159 | + if ($this->requestIsForSubtree(['calendars', 'public-calendars', 'system-calendars', 'principals'])) { |
|
160 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin()); |
|
161 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\ICSExportPlugin\ICSExportPlugin(\OC::$server->getConfig(), \OC::$server->getLogger())); |
|
162 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin(\OC::$server->getConfig())); |
|
163 | + if (\OC::$server->getConfig()->getAppValue('dav', 'sendInvitations', 'yes') === 'yes') { |
|
164 | + $this->server->addPlugin(\OC::$server->query(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class)); |
|
165 | + } |
|
166 | + |
|
167 | + $this->server->addPlugin(\OC::$server->get(\OCA\DAV\CalDAV\Trashbin\Plugin::class)); |
|
168 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\WebcalCaching\Plugin($request)); |
|
169 | + $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin()); |
|
170 | + |
|
171 | + $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin()); |
|
172 | + $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest(), \OC::$server->getConfig())); |
|
173 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin( |
|
174 | + \OC::$server->getConfig(), |
|
175 | + \OC::$server->getURLGenerator() |
|
176 | + )); |
|
177 | + } |
|
178 | + |
|
179 | + // addressbook plugins |
|
180 | + if ($this->requestIsForSubtree(['addressbooks', 'principals'])) { |
|
181 | + $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest(), \OC::$server->getConfig())); |
|
182 | + $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin()); |
|
183 | + $this->server->addPlugin(new VCFExportPlugin()); |
|
184 | + $this->server->addPlugin(new MultiGetExportPlugin()); |
|
185 | + $this->server->addPlugin(new HasPhotoPlugin()); |
|
186 | + $this->server->addPlugin(new ImageExportPlugin(new PhotoCache( |
|
187 | + \OC::$server->getAppDataDir('dav-photocache'), |
|
188 | + \OC::$server->getLogger()) |
|
189 | + )); |
|
190 | + } |
|
191 | + |
|
192 | + // system tags plugins |
|
193 | + $this->server->addPlugin(new SystemTagPlugin( |
|
194 | + \OC::$server->getSystemTagManager(), |
|
195 | + \OC::$server->getGroupManager(), |
|
196 | + \OC::$server->getUserSession() |
|
197 | + )); |
|
198 | + |
|
199 | + // comments plugin |
|
200 | + $this->server->addPlugin(new CommentsPlugin( |
|
201 | + \OC::$server->getCommentsManager(), |
|
202 | + \OC::$server->getUserSession() |
|
203 | + )); |
|
204 | + |
|
205 | + $this->server->addPlugin(new CopyEtagHeaderPlugin()); |
|
206 | + $this->server->addPlugin(new ChunkingPlugin()); |
|
207 | + |
|
208 | + // allow setup of additional plugins |
|
209 | + $dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event); |
|
210 | + |
|
211 | + // Some WebDAV clients do require Class 2 WebDAV support (locking), since |
|
212 | + // we do not provide locking we emulate it using a fake locking plugin. |
|
213 | + if ($request->isUserAgent([ |
|
214 | + '/WebDAVFS/', |
|
215 | + '/OneNote/', |
|
216 | + '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
217 | + ])) { |
|
218 | + $this->server->addPlugin(new FakeLockerPlugin()); |
|
219 | + } |
|
220 | + |
|
221 | + if (BrowserErrorPagePlugin::isBrowserRequest($request)) { |
|
222 | + $this->server->addPlugin(new BrowserErrorPagePlugin()); |
|
223 | + } |
|
224 | + |
|
225 | + $lazySearchBackend = new LazySearchBackend(); |
|
226 | + $this->server->addPlugin(new SearchPlugin($lazySearchBackend)); |
|
227 | + |
|
228 | + // wait with registering these until auth is handled and the filesystem is setup |
|
229 | + $this->server->on('beforeMethod:*', function () use ($root, $lazySearchBackend) { |
|
230 | + // custom properties plugin must be the last one |
|
231 | + $userSession = \OC::$server->getUserSession(); |
|
232 | + $user = $userSession->getUser(); |
|
233 | + if ($user !== null) { |
|
234 | + $view = \OC\Files\Filesystem::getView(); |
|
235 | + $this->server->addPlugin( |
|
236 | + new FilesPlugin( |
|
237 | + $this->server->tree, |
|
238 | + \OC::$server->getConfig(), |
|
239 | + $this->request, |
|
240 | + \OC::$server->getPreviewManager(), |
|
241 | + false, |
|
242 | + !\OC::$server->getConfig()->getSystemValue('debug', false) |
|
243 | + ) |
|
244 | + ); |
|
245 | + |
|
246 | + $this->server->addPlugin( |
|
247 | + new \Sabre\DAV\PropertyStorage\Plugin( |
|
248 | + new CustomPropertiesBackend( |
|
249 | + $this->server->tree, |
|
250 | + \OC::$server->getDatabaseConnection(), |
|
251 | + \OC::$server->getUserSession()->getUser() |
|
252 | + ) |
|
253 | + ) |
|
254 | + ); |
|
255 | + if ($view !== null) { |
|
256 | + $this->server->addPlugin( |
|
257 | + new QuotaPlugin($view)); |
|
258 | + } |
|
259 | + $this->server->addPlugin( |
|
260 | + new TagsPlugin( |
|
261 | + $this->server->tree, \OC::$server->getTagManager() |
|
262 | + ) |
|
263 | + ); |
|
264 | + // TODO: switch to LazyUserFolder |
|
265 | + $userFolder = \OC::$server->getUserFolder(); |
|
266 | + $this->server->addPlugin(new SharesPlugin( |
|
267 | + $this->server->tree, |
|
268 | + $userSession, |
|
269 | + $userFolder, |
|
270 | + \OC::$server->getShareManager() |
|
271 | + )); |
|
272 | + $this->server->addPlugin(new CommentPropertiesPlugin( |
|
273 | + \OC::$server->getCommentsManager(), |
|
274 | + $userSession |
|
275 | + )); |
|
276 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin()); |
|
277 | + if ($view !== null) { |
|
278 | + $this->server->addPlugin(new FilesReportPlugin( |
|
279 | + $this->server->tree, |
|
280 | + $view, |
|
281 | + \OC::$server->getSystemTagManager(), |
|
282 | + \OC::$server->getSystemTagObjectMapper(), |
|
283 | + \OC::$server->getTagManager(), |
|
284 | + $userSession, |
|
285 | + \OC::$server->getGroupManager(), |
|
286 | + $userFolder, |
|
287 | + \OC::$server->getAppManager() |
|
288 | + )); |
|
289 | + $lazySearchBackend->setBackend(new \OCA\DAV\Files\FileSearchBackend( |
|
290 | + $this->server->tree, |
|
291 | + $user, |
|
292 | + \OC::$server->getRootFolder(), |
|
293 | + \OC::$server->getShareManager(), |
|
294 | + $view |
|
295 | + )); |
|
296 | + } |
|
297 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\BirthdayCalendar\EnablePlugin( |
|
298 | + \OC::$server->getConfig(), |
|
299 | + \OC::$server->query(BirthdayService::class) |
|
300 | + )); |
|
301 | + $this->server->addPlugin(new AppleProvisioningPlugin( |
|
302 | + \OC::$server->getUserSession(), |
|
303 | + \OC::$server->getURLGenerator(), |
|
304 | + \OC::$server->getThemingDefaults(), |
|
305 | + \OC::$server->getRequest(), |
|
306 | + \OC::$server->getL10N('dav'), |
|
307 | + function () { |
|
308 | + return UUIDUtil::getUUID(); |
|
309 | + } |
|
310 | + )); |
|
311 | + } |
|
312 | + |
|
313 | + // register plugins from apps |
|
314 | + $pluginManager = new PluginManager( |
|
315 | + \OC::$server, |
|
316 | + \OC::$server->getAppManager() |
|
317 | + ); |
|
318 | + foreach ($pluginManager->getAppPlugins() as $appPlugin) { |
|
319 | + $this->server->addPlugin($appPlugin); |
|
320 | + } |
|
321 | + foreach ($pluginManager->getAppCollections() as $appCollection) { |
|
322 | + $root->addChild($appCollection); |
|
323 | + } |
|
324 | + }); |
|
325 | + |
|
326 | + $this->server->addPlugin( |
|
327 | + new PropfindCompressionPlugin() |
|
328 | + ); |
|
329 | + } |
|
330 | + |
|
331 | + public function exec() { |
|
332 | + $this->server->exec(); |
|
333 | + } |
|
334 | + |
|
335 | + private function requestIsForSubtree(array $subTrees): bool { |
|
336 | + foreach ($subTrees as $subTree) { |
|
337 | + $subTree = trim($subTree, ' /'); |
|
338 | + if (strpos($this->server->getRequestUri(), $subTree.'/') === 0) { |
|
339 | + return true; |
|
340 | + } |
|
341 | + } |
|
342 | + return false; |
|
343 | + } |
|
344 | 344 | } |