aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/CalDAV
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/lib/CalDAV')
-rw-r--r--apps/dav/lib/CalDAV/Calendar.php6
-rw-r--r--apps/dav/lib/CalDAV/CalendarProvider.php35
-rw-r--r--apps/dav/lib/CalDAV/EmbeddedCalDavServer.php4
3 files changed, 38 insertions, 7 deletions
diff --git a/apps/dav/lib/CalDAV/Calendar.php b/apps/dav/lib/CalDAV/Calendar.php
index dd3a4cf3f69..deb00caa93d 100644
--- a/apps/dav/lib/CalDAV/Calendar.php
+++ b/apps/dav/lib/CalDAV/Calendar.php
@@ -36,7 +36,7 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IRestorable, IShareable
public function __construct(
BackendInterface $caldavBackend,
- $calendarInfo,
+ array $calendarInfo,
IL10N $l10n,
private IConfig $config,
private LoggerInterface $logger,
@@ -60,6 +60,10 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IRestorable, IShareable
$this->l10n = $l10n;
}
+ public function getUri(): string {
+ return $this->calendarInfo['uri'];
+ }
+
/**
* {@inheritdoc}
* @throws Forbidden
diff --git a/apps/dav/lib/CalDAV/CalendarProvider.php b/apps/dav/lib/CalDAV/CalendarProvider.php
index 3cc4039ed36..a8b818e59aa 100644
--- a/apps/dav/lib/CalDAV/CalendarProvider.php
+++ b/apps/dav/lib/CalDAV/CalendarProvider.php
@@ -36,9 +36,14 @@ class CalendarProvider implements ICalendarProvider {
});
}
+ $additionalProperties = $this->getAdditionalPropertiesForCalendars($calendarInfos);
$iCalendars = [];
foreach ($calendarInfos as $calendarInfo) {
- $calendarInfo = array_merge($calendarInfo, $this->getAdditionalProperties($calendarInfo['principaluri'], $calendarInfo['uri']));
+ $user = str_replace('principals/users/', '', $calendarInfo['principaluri']);
+ $path = 'calendars/' . $user . '/' . $calendarInfo['uri'];
+
+ $calendarInfo = array_merge($calendarInfo, $additionalProperties[$path] ?? []);
+
$calendar = new Calendar($this->calDavBackend, $calendarInfo, $this->l10n, $this->config, $this->logger);
$iCalendars[] = new CalendarImpl(
$calendar,
@@ -49,16 +54,34 @@ class CalendarProvider implements ICalendarProvider {
return $iCalendars;
}
- public function getAdditionalProperties(string $principalUri, string $calendarUri): array {
- $user = str_replace('principals/users/', '', $principalUri);
- $path = 'calendars/' . $user . '/' . $calendarUri;
+ /**
+ * @param array{
+ * principaluri: string,
+ * uri: string,
+ * }[] $uris
+ * @return array<string, array<string, string|bool>>
+ */
+ private function getAdditionalPropertiesForCalendars(array $uris): array {
+ $calendars = [];
+ foreach ($uris as $uri) {
+ /** @var string $user */
+ $user = str_replace('principals/users/', '', $uri['principaluri']);
+ if (!array_key_exists($user, $calendars)) {
+ $calendars[$user] = [];
+ }
+ $calendars[$user][] = 'calendars/' . $user . '/' . $uri['uri'];
+ }
- $properties = $this->propertyMapper->findPropertiesByPath($user, $path);
+ $properties = $this->propertyMapper->findPropertiesByPathsAndUsers($calendars);
$list = [];
foreach ($properties as $property) {
if ($property instanceof Property) {
- $list[$property->getPropertyname()] = match ($property->getPropertyname()) {
+ if (!isset($list[$property->getPropertypath()])) {
+ $list[$property->getPropertypath()] = [];
+ }
+
+ $list[$property->getPropertypath()][$property->getPropertyname()] = match ($property->getPropertyname()) {
'{http://owncloud.org/ns}calendar-enabled' => (bool)$property->getPropertyvalue(),
default => $property->getPropertyvalue()
};
diff --git a/apps/dav/lib/CalDAV/EmbeddedCalDavServer.php b/apps/dav/lib/CalDAV/EmbeddedCalDavServer.php
index 21d8c06fa99..d9d6d840c5e 100644
--- a/apps/dav/lib/CalDAV/EmbeddedCalDavServer.php
+++ b/apps/dav/lib/CalDAV/EmbeddedCalDavServer.php
@@ -20,6 +20,7 @@ use OCA\DAV\Connector\Sabre\DavAclPlugin;
use OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin;
use OCA\DAV\Connector\Sabre\LockPlugin;
use OCA\DAV\Connector\Sabre\MaintenancePlugin;
+use OCA\DAV\Connector\Sabre\PropFindPreloadNotifyPlugin;
use OCA\DAV\Events\SabrePluginAuthInitEvent;
use OCA\DAV\RootCollection;
use OCA\Theming\ThemingDefaults;
@@ -96,6 +97,9 @@ class EmbeddedCalDavServer {
$this->server->addPlugin(Server::get(\OCA\DAV\CalDAV\Schedule\IMipPlugin::class));
}
+ // collection preload plugin
+ $this->server->addPlugin(new PropFindPreloadNotifyPlugin());
+
// wait with registering these until auth is handled and the filesystem is setup
$this->server->on('beforeMethod:*', function () use ($root): void {
// register plugins from apps