mirror of
https://github.com/nextcloud/server.git
synced 2026-02-28 04:20:37 -05:00
Convert the old principal to the new principal before getting calendars
This commit is contained in:
parent
ffc2950393
commit
4e2f9ce05b
1 changed files with 13 additions and 2 deletions
|
|
@ -138,6 +138,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
* @return array
|
||||
*/
|
||||
function getCalendarsForUser($principalUri) {
|
||||
$principalUri = $this->convertPrincipal($principalUri, true);
|
||||
$fields = array_values($this->propertyMap);
|
||||
$fields[] = 'id';
|
||||
$fields[] = 'uri';
|
||||
|
|
@ -164,7 +165,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
$calendar = [
|
||||
'id' => $row['id'],
|
||||
'uri' => $row['uri'],
|
||||
'principaluri' => $row['principaluri'],
|
||||
'principaluri' => $this->convertPrincipal($row['principaluri'], false),
|
||||
'{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'),
|
||||
'{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0',
|
||||
'{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components),
|
||||
|
|
@ -1093,7 +1094,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
$newValues = [];
|
||||
|
||||
foreach($mutations as $propertyName=>$propertyValue) {
|
||||
if ($propertyName === '{http://calendarserver.org/ns/}source') {
|
||||
if ($propertyName === '{http://calendarserver.org/ns/}source') {
|
||||
$newValues['source'] = $propertyValue->getHref();
|
||||
} else {
|
||||
$fieldName = $this->subscriptionPropertyMap[$propertyName];
|
||||
|
|
@ -1373,4 +1374,14 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
return $this->sharingBackend->applyShareAcl($resourceId, $acl);
|
||||
}
|
||||
|
||||
private function convertPrincipal($principalUri, $toV2) {
|
||||
if ($this->principalBackend->getPrincipalPrefix() === 'principals') {
|
||||
list(, $name) = URLUtil::splitPath($principalUri);
|
||||
if ($toV2 === true) {
|
||||
return "principals/users/$name";
|
||||
}
|
||||
return "principals/$name";
|
||||
}
|
||||
return $principalUri;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue