-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Modernize the dav app #30335
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
Closed
Closed
Modernize the dav app #30335
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
c8c8f93
Move createSubscription and deleteSubscription event handlers to
tcitworld bfdfd3e
Remove uses of LegacyDispatcher for create/delete subscriptions
tcitworld dfa2cc3
Move every event to listeners and remove all uses of legacy dispatcher
tcitworld 10af3ab
Add tests for new Listeners
tcitworld 180e695
Remove usages of legacyDispatcher in CardDAVBackend
tcitworld ab07629
Update some depreciated calls
tcitworld 08abaae
Fix doctype of param passed to deleteContact
tcitworld 4827bc7
Improve OCA\DAV\Connector\Sabre\Principal
tcitworld aa7994f
Improve OCA\DAV\Tests\unit\CardDAV\AddressBookImplTest
tcitworld 3a3a1a0
Move uses of ILogger to LoggerInterface
tcitworld fed15f9
Move some events to IEventDispatcher
tcitworld c304561
Replace calls to Sabre's depreciated getPropertiesForPath with getPro…
tcitworld 981b99c
Remove more depreciated calls
tcitworld dcc9c70
Remove HookManager and replace with UserChangeListener
tcitworld 7a5f4af
Modernize endpoints
tcitworld d739f92
Modernize Sabre Connector
tcitworld 244aaa7
Add @template-implements metadata for listeners
tcitworld 57ddf28
Remove CalendarManager registration
tcitworld fccc89d
Various fixes
tcitworld 041526d
Improve tests
tcitworld 3d42336
Improve CommentsEntityEvent
tcitworld 9246d06
Use PHP 7.4 typed properties
tcitworld 6d6008d
Rebasing, cs and more typing
tcitworld File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Modernize endpoints
Signed-off-by: Thomas Citharel <[email protected]>
- Loading branch information
commit 7a5f4afd3285727ae7f51b83fb9ca2129aca2cc9
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| * @author John Molakvoæ <[email protected]> | ||
| * @author Lukas Reschke <[email protected]> | ||
| * @author Morris Jobke <[email protected]> | ||
| * @author Thomas Citharel <[email protected]> | ||
| * @author Thomas Müller <[email protected]> | ||
| * | ||
| * @license AGPL-3.0 | ||
|
|
@@ -26,48 +27,85 @@ | |
| * | ||
| */ | ||
| // Backends | ||
| use OC\Authentication\TwoFactorAuth\Manager as TwoFactorAuthManager; | ||
| use OC\Files\AppData\Factory as AppDataFactory; | ||
| use OC\KnownUser\KnownUserService; | ||
| use OC\Security\Bruteforce\Throttler; | ||
| use OCA\DAV\AppInfo\PluginManager; | ||
| use OCA\DAV\CalDAV\Proxy\ProxyMapper; | ||
| use OCA\DAV\CardDAV\AddressBookRoot; | ||
| use OCA\DAV\CardDAV\CardDavBackend; | ||
| use OCA\DAV\CardDAV\ImageExportPlugin; | ||
| use OCA\DAV\CardDAV\PhotoCache; | ||
| use OCA\DAV\Connector\LegacyDAVACL; | ||
| use OCA\DAV\Connector\Sabre\Auth; | ||
| use OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin; | ||
| use OCA\DAV\Connector\Sabre\MaintenancePlugin; | ||
| use OCA\DAV\Connector\Sabre\Principal; | ||
| use OCP\App\IAppManager; | ||
| use OCP\EventDispatcher\IEventDispatcher; | ||
| use OCP\IConfig; | ||
| use OCP\IDBConnection; | ||
| use OCP\IGroupManager; | ||
| use OCP\IRequest; | ||
| use OCP\IUserManager; | ||
| use OCP\IUserSession; | ||
| use OCP\L10N\IFactory as IL10NFactory; | ||
| use OCP\Share\IManager as IShareManager; | ||
| use Psr\Log\LoggerInterface; | ||
| use Sabre\CalDAV\Principal\Collection; | ||
| use Sabre\CardDAV\Plugin; | ||
| use Sabre\CardDAV\VCFExportPlugin; | ||
| use Sabre\DAV\Auth\Plugin as AuthPlugin; | ||
| use Sabre\DAV\Browser\Plugin as BrowserPlugin; | ||
| use Sabre\DAV\Server; | ||
| use Sabre\DAV\Sync\Plugin as SyncPlugin; | ||
|
|
||
| /** @var IUserSession $userSession */ | ||
| $userSession = \OC::$server->get(IUserSession::class); | ||
| /** @var IRequest $request */ | ||
| $request = \OC::$server->get(IRequest::class); | ||
| /** @var IUserManager $userManager */ | ||
| $userManager = \OC::$server->get(IUserManager::class); | ||
| /** @var IGroupManager $groupManager */ | ||
| $groupManager = \OC::$server->get(IGroupManager::class); | ||
| /** @var IConfig $config */ | ||
| $config = \OC::$server->get(IConfig::class); | ||
| /** @var IL10NFactory $l10nFactory */ | ||
| $l10nFactory = \OC::$server->get(IL10NFactory::class); | ||
| /** @var LoggerInterface $logger */ | ||
| $logger = \OC::$server->get(LoggerInterface::class); | ||
|
|
||
| $authBackend = new Auth( | ||
| \OC::$server->getSession(), | ||
| \OC::$server->getUserSession(), | ||
| \OC::$server->getRequest(), | ||
| \OC::$server->getTwoFactorAuthManager(), | ||
| \OC::$server->getBruteForceThrottler(), | ||
| $userSession->getSession(), | ||
| $userSession, | ||
| $request, | ||
| \OC::$server->get(TwoFactorAuthManager::class), | ||
| \OC::$server->get(Throttler::class), | ||
| 'principals/' | ||
| ); | ||
| $principalBackend = new Principal( | ||
| \OC::$server->getUserManager(), | ||
| \OC::$server->getGroupManager(), | ||
| \OC::$server->getShareManager(), | ||
| \OC::$server->getUserSession(), | ||
| \OC::$server->getAppManager(), | ||
| \OC::$server->query(\OCA\DAV\CalDAV\Proxy\ProxyMapper::class), | ||
| $userManager, | ||
| $groupManager, | ||
| \OC::$server->get(IShareManager::class), | ||
| $userSession, | ||
| \OC::$server->get(IAppManager::class), | ||
| \OC::$server->get(ProxyMapper::class), | ||
| \OC::$server->get(KnownUserService::class), | ||
| \OC::$server->getConfig(), | ||
| \OC::$server->getL10NFactory(), | ||
| $config, | ||
| $l10nFactory, | ||
| 'principals/' | ||
| ); | ||
| $db = \OC::$server->getDatabaseConnection(); | ||
| $cardDavBackend = new CardDavBackend($db, $principalBackend, \OC::$server->getUserManager(), \OC::$server->getGroupManager(), \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class)); | ||
|
|
||
| $debugging = \OC::$server->getConfig()->getSystemValue('debug', false); | ||
| $cardDavBackend = new CardDavBackend(\OC::$server->get(IDBConnection::class), $principalBackend, $userManager, $groupManager, \OC::$server->get(IEventDispatcher::class)); | ||
|
|
||
| $debugging = $config->getSystemValue('debug', false); | ||
|
|
||
| // Root nodes | ||
| $principalCollection = new \Sabre\CalDAV\Principal\Collection($principalBackend); | ||
| $principalCollection = new Collection($principalBackend); | ||
| $principalCollection->disableListing = !$debugging; // Disable listing | ||
|
|
||
| $pluginManager = new PluginManager(\OC::$server, \OC::$server->query(IAppManager::class)); | ||
| $pluginManager = new PluginManager(\OC::$server, \OC::$server->get(IAppManager::class)); | ||
| $addressBookRoot = new AddressBookRoot($principalBackend, $cardDavBackend, $pluginManager); | ||
| $addressBookRoot->disableListing = !$debugging; // Disable listing | ||
|
|
||
|
|
@@ -77,27 +115,27 @@ | |
| ]; | ||
|
|
||
| // Fire up server | ||
| $server = new \Sabre\DAV\Server($nodes); | ||
| $server = new Server($nodes); | ||
| $server::$exposeVersion = false; | ||
| $server->httpRequest->setUrl(\OC::$server->getRequest()->getRequestUri()); | ||
| $server->httpRequest->setUrl($request->getRequestUri()); | ||
| $server->setBaseUri($baseuri); | ||
| // Add plugins | ||
| $server->addPlugin(new MaintenancePlugin(\OC::$server->getConfig(), \OC::$server->getL10N('dav'))); | ||
| $server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, 'ownCloud')); | ||
| $server->addPlugin(new MaintenancePlugin($config, $l10nFactory->get('dav'))); | ||
| $server->addPlugin(new AuthPlugin($authBackend)); | ||
| $server->addPlugin(new Plugin()); | ||
|
|
||
| $server->addPlugin(new LegacyDAVACL()); | ||
| if ($debugging) { | ||
| $server->addPlugin(new Sabre\DAV\Browser\Plugin()); | ||
| $server->addPlugin(new BrowserPlugin()); | ||
| } | ||
|
|
||
| $server->addPlugin(new \Sabre\DAV\Sync\Plugin()); | ||
| $server->addPlugin(new \Sabre\CardDAV\VCFExportPlugin()); | ||
| $server->addPlugin(new \OCA\DAV\CardDAV\ImageExportPlugin(new \OCA\DAV\CardDAV\PhotoCache( | ||
| \OC::$server->getAppDataDir('dav-photocache'), | ||
| \OC::$server->getLogger() | ||
| $server->addPlugin(new SyncPlugin()); | ||
| $server->addPlugin(new VCFExportPlugin()); | ||
| $server->addPlugin(new ImageExportPlugin(new PhotoCache( | ||
| \OC::$server->get(AppDataFactory::class)->get('dav-photocache'), | ||
| $logger | ||
| ))); | ||
| $server->addPlugin(new ExceptionLoggerPlugin('carddav', \OC::$server->getLogger())); | ||
| $server->addPlugin(new ExceptionLoggerPlugin('carddav', $logger)); | ||
|
|
||
| // And off we go! | ||
| $server->exec(); | ||
| $server->start(); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the recommended way to get the actual
ISessionobject there?getSessionexists onOC\User\Sessionbut notIUserSession.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does
\OC::$server->get(IUserSession::class)work?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs an
ISession, not anIUserSession.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\OC::$server->get(ISession::class);should workThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, it's registered indeed
server/lib/private/Server.php
Lines 1353 to 1355 in 9026455