When sharing calendars and addressbooks the principal has to be verified to be valid

d3fb8fcdd3

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-04-23 13:48:39 +02:00 committed by John Molakvoæ (skjnldsv)
parent ed0069b8e6
commit 3a133b151f
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF
4 changed files with 18 additions and 5 deletions

View File

@ -203,7 +203,7 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
} }
$this->caldavBackend->updateShares($this, [], [ $this->caldavBackend->updateShares($this, [], [
'href' => $principal $principal
]); ]);
return; return;
} }

View File

@ -181,7 +181,7 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable {
} }
$this->carddavBackend->updateShares($this, [], [ $this->carddavBackend->updateShares($this, [], [
'href' => $principal $principal
]); ]);
return; return;
} }

View File

@ -325,6 +325,13 @@ class Principal implements BackendInterface {
return $this->principalPrefix . '/' . $user->getUID(); return $this->principalPrefix . '/' . $user->getUID();
} }
} }
if (substr($uri, 0, 10) === 'principal:') {
$principal = substr($uri, 10);
$principal = $this->getPrincipalByPath($principal);
if ($principal !== null) {
return $principal['uri'];
}
}
return null; return null;
} }

View File

@ -67,14 +67,20 @@ class Backend {
* @param string[] $add * @param string[] $add
* @param string[] $remove * @param string[] $remove
*/ */
public function updateShares($shareable, $add, $remove) { public function updateShares(IShareable $shareable, array $add, array $remove) {
foreach($add as $element) { foreach($add as $element) {
$principal = $this->principalBackend->findByUri($element['href'], '');
if ($principal !== '') {
$this->shareWith($shareable, $element); $this->shareWith($shareable, $element);
} }
}
foreach($remove as $element) { foreach($remove as $element) {
$principal = $this->principalBackend->findByUri($element, '');
if ($principal !== '') {
$this->unshare($shareable, $element); $this->unshare($shareable, $element);
} }
} }
}
/** /**
* @param IShareable $shareable * @param IShareable $shareable