Skip to content

Commit

Permalink
Fix old carddav endpoint
Browse files Browse the repository at this point in the history
* User proper principals/users/
* Fix test expectations

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
  • Loading branch information
rullzer committed Dec 15, 2016
1 parent 710be0c commit 7d65239
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
14 changes: 7 additions & 7 deletions apps/dav/appinfo/v1/carddav.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,28 @@
\OC::$server->getUserSession(),
\OC::$server->getRequest(),
\OC::$server->getTwoFactorAuthManager(),
\OC::$server->getBruteForceThrottler(),
'principals/'
\OC::$server->getBruteForceThrottler()
);
$principalBackend = new Principal(
\OC::$server->getUserManager(),
\OC::$server->getGroupManager(),
'principals/'
\OC::$server->getGroupManager()
);
$db = \OC::$server->getDatabaseConnection();
$cardDavBackend = new CardDavBackend($db, $principalBackend, \OC::$server->getUserManager());

$debugging = \OC::$server->getConfig()->getSystemValue('debug', false);

// Root nodes
$principalCollection = new \Sabre\CalDAV\Principal\Collection($principalBackend);
$principalCollection = new \Sabre\CalDAV\Principal\Collection($principalBackend, 'principals/users/');
$principalCollection->disableListing = !$debugging; // Disable listing

$addressBookRoot = new AddressBookRoot($principalBackend, $cardDavBackend);
$addressBookRoot = new AddressBookRoot($principalBackend, $cardDavBackend, 'principals/users/');
$addressBookRoot->disableListing = !$debugging; // Disable listing

$principals = new \Sabre\DAV\SimpleCollection('principals', [$principalCollection]);

$nodes = array(
$principalCollection,
$principals,
$addressBookRoot,
);

Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/CardDAV/AddressBookRoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function getChildForPrincipal(array $principal) {

function getName() {

if ($this->principalPrefix === 'principals') {
if ($this->principalPrefix === 'principals/users/') {
return parent::getName();
}
// Grabbing all the components of the principal path.
Expand Down
1 change: 1 addition & 0 deletions apps/dav/lib/Connector/Sabre/Principal.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function __construct(IUserManager $userManager,
*/
public function getPrincipalsByPrefix($prefixPath) {
$principals = [];
$prefixPath = trim($prefixPath, '/');

if ($prefixPath === $this->principalPrefix) {
foreach($this->userManager->search('') as $user) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@
<key>$uidstype:</key>
<value>__uids__</value>
</substitution>
<substitution>
<key>$userstype:</key>
<value>users</value>
</substitution>
<substitution>
<key>$groupstype:</key>
<value>groups</value>
Expand All @@ -208,7 +212,7 @@
</substitution>
<substitution>
<key>$principals_users:</key>
<value>$principalcollection:</value>
<value>$principalcollection:$userstype:/</value>
</substitution>
<substitution>
<key>$principals_groups:</key>
Expand Down

0 comments on commit 7d65239

Please sign in to comment.