Add auto discovery

This commit is contained in:
philipp lang 2022-10-06 23:47:35 +02:00
parent 25d31e7115
commit 57f47dd69c
3 changed files with 9 additions and 2 deletions

View File

@ -33,7 +33,7 @@ class AddressBookBackend extends AbstractBackend
*/
public function getAddressBooksForUser($principalUri)
{
if (1 !== preg_match('/^\/principals\/(.*)$/', $principalUri, $matches)) {
if (1 !== preg_match('/^principals\/(.*)$/', $principalUri, $matches)) {
return [];
}

View File

@ -151,6 +151,11 @@ class Principal implements PrincipalBackendInterface
*/
public function getGroupMembership($principal)
{
if (1 !== preg_match('/^\/principals\/(.*)$/', $principal, $matches)) {
return null;
}
return ['addressbooks/'.$matches[1]];
}
/**
@ -171,7 +176,7 @@ class Principal implements PrincipalBackendInterface
{
return [
'{DAV:}displayname' => $user->name,
'uri' => '/principals/'.$user->email,
'uri' => 'principals/'.$user->email,
'{http://sabredav.org/ns}email-address' => $user->email,
];
}

View File

@ -10,6 +10,7 @@ use Sabre\CardDAV\Plugin as CardDAVPlugin;
use Sabre\DAV\Auth\Plugin as AuthPlugin;
use Sabre\DAV\Browser\Plugin as BrowserPlugin;
use Sabre\DAVACL\AbstractPrincipalCollection;
use Sabre\DAVACL\Plugin as AclPlugin;
use Sabre\DAVACL\PrincipalCollection;
class ServiceProvider extends BaseServiceProvider
@ -57,6 +58,7 @@ class ServiceProvider extends BaseServiceProvider
new BrowserPlugin(),
new AuthPlugin($authBackend),
new CardDAVPlugin(),
new AclPlugin(),
];
}
}