Skip to content

Commit 657854e

Browse files
CopilotGVodyanov
andcommitted
Fix 404 on delegated calendars: handle proxy principal URLs in Plugin::getCalendarHomeForPrincipal
Co-authored-by: GVodyanov <76647797+GVodyanov@users.noreply.github.com> Agent-Logs-Url: https://github.com/GVodyanov/nextcloud-server/sessions/e410e30e-7bf7-43cd-bb30-1f9d9cfedcf3
1 parent 5644283 commit 657854e

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

apps/dav/lib/CalDAV/Plugin.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,20 @@ class Plugin extends \Sabre\CalDAV\Plugin {
1717
* This function should return null in case a principal did not have
1818
* a calendar home.
1919
*
20+
* For calendar-proxy group principals (e.g. principals/users/alice/calendar-proxy-write),
21+
* this returns the calendar home of the principal owner (alice), so that CalDAV clients
22+
* can discover and access the delegated calendar home correctly.
23+
*
2024
* @param string $principalUrl
2125
* @return string|null
2226
*/
2327
public function getCalendarHomeForPrincipal($principalUrl) {
28+
// calendar-proxy group principals must resolve to the owner's calendar home
29+
if (str_ends_with($principalUrl, '/calendar-proxy-write') || str_ends_with($principalUrl, '/calendar-proxy-read')) {
30+
$ownerPrincipalUrl = substr($principalUrl, 0, strrpos($principalUrl, '/'));
31+
return $this->getCalendarHomeForPrincipal($ownerPrincipalUrl);
32+
}
33+
2434
if (strrpos($principalUrl, 'principals/users', -strlen($principalUrl)) !== false) {
2535
[, $principalId] = \Sabre\Uri\split($principalUrl);
2636
return self::CALENDAR_ROOT . '/' . $principalId;

apps/dav/tests/unit/CalDAV/PluginTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ public static function linkProvider(): array {
3333
'principals/calendar-rooms/Room-ABC',
3434
'system-calendars/calendar-rooms/Room-ABC',
3535
],
36+
// calendar-proxy-write and calendar-proxy-read group principals must
37+
// resolve to the owner's calendar home so that delegates can discover
38+
// the delegated calendar home via PROPFIND on the proxy group principal.
39+
[
40+
'principals/users/alice/calendar-proxy-write',
41+
'calendars/alice',
42+
],
43+
[
44+
'principals/users/alice/calendar-proxy-read',
45+
'calendars/alice',
46+
],
3647
];
3748
}
3849

0 commit comments

Comments
 (0)