From d03f7d7aa893f2c499e3a3e1d8b839adce9ce519 Mon Sep 17 00:00:00 2001 From: SebastianKrupinski Date: Fri, 13 Nov 2026 19:05:50 -0500 Subject: [PATCH] fix: index conference property Signed-off-by: SebastianKrupinski --- apps/dav/appinfo/info.xml | 2 +- .../composer/composer/autoload_classmap.php | 1 + .../dav/composer/composer/autoload_static.php | 1 + apps/dav/lib/CalDAV/CalDavBackend.php | 3 +- .../BuildCalendarSearchIndexBackgroundJob.php | 17 ++++--- .../Version3000Date20261112000000.php | 44 +++++++++++++++++++ .../tests/unit/CalDAV/CalDavBackendTest.php | 38 ++++++++++++++++ lib/public/Calendar/ICalendarQuery.php | 5 +++ 8 files changed, 104 insertions(+), 7 deletions(-) create mode 100644 apps/dav/lib/Migration/Version3000Date20261112000000.php diff --git a/apps/dav/appinfo/info.xml b/apps/dav/appinfo/info.xml index a82e389b50792..e592f3eb3ff4e 100644 --- a/apps/dav/appinfo/info.xml +++ b/apps/dav/appinfo/info.xml @@ -10,7 +10,7 @@ WebDAV WebDAV endpoint WebDAV endpoint - 3.0.0-dev.2 + 3.0.0-dev.3 agpl owncloud.org DAV diff --git a/apps/dav/composer/composer/autoload_classmap.php b/apps/dav/composer/composer/autoload_classmap.php index 9af252d67a7e2..e3a9319d8f8e8 100644 --- a/apps/dav/composer/composer/autoload_classmap.php +++ b/apps/dav/composer/composer/autoload_classmap.php @@ -423,6 +423,7 @@ 'OCA\\DAV\\Migration\\Version1039Date20260408000001' => $baseDir . '/../lib/Migration/Version1039Date20260408000001.php', 'OCA\\DAV\\Migration\\Version1040Date20260805000000' => $baseDir . '/../lib/Migration/Version1040Date20260805000000.php', 'OCA\\DAV\\Migration\\Version3000Date20260828000000' => $baseDir . '/../lib/Migration/Version3000Date20260828000000.php', + 'OCA\\DAV\\Migration\\Version3000Date20261112000000' => $baseDir . '/../lib/Migration/Version3000Date20261112000000.php', 'OCA\\DAV\\Model\\ExampleEvent' => $baseDir . '/../lib/Model/ExampleEvent.php', 'OCA\\DAV\\Paginate\\LimitedCopyIterator' => $baseDir . '/../lib/Paginate/LimitedCopyIterator.php', 'OCA\\DAV\\Paginate\\PaginateCache' => $baseDir . '/../lib/Paginate/PaginateCache.php', diff --git a/apps/dav/composer/composer/autoload_static.php b/apps/dav/composer/composer/autoload_static.php index 5321ae3251029..d44afb55462a2 100644 --- a/apps/dav/composer/composer/autoload_static.php +++ b/apps/dav/composer/composer/autoload_static.php @@ -438,6 +438,7 @@ class ComposerStaticInitDAV 'OCA\\DAV\\Migration\\Version1039Date20260408000001' => __DIR__ . '/..' . '/../lib/Migration/Version1039Date20260408000001.php', 'OCA\\DAV\\Migration\\Version1040Date20260805000000' => __DIR__ . '/..' . '/../lib/Migration/Version1040Date20260805000000.php', 'OCA\\DAV\\Migration\\Version3000Date20260828000000' => __DIR__ . '/..' . '/../lib/Migration/Version3000Date20260828000000.php', + 'OCA\\DAV\\Migration\\Version3000Date20261112000000' => __DIR__ . '/..' . '/../lib/Migration/Version3000Date20261112000000.php', 'OCA\\DAV\\Model\\ExampleEvent' => __DIR__ . '/..' . '/../lib/Model/ExampleEvent.php', 'OCA\\DAV\\Paginate\\LimitedCopyIterator' => __DIR__ . '/..' . '/../lib/Paginate/LimitedCopyIterator.php', 'OCA\\DAV\\Paginate\\PaginateCache' => __DIR__ . '/..' . '/../lib/Paginate/PaginateCache.php', diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index c32538c82e4a6..ad904095bf78d 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -189,7 +189,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription 'SUMMARY', 'ATTENDEE', 'CONTACT', - 'ORGANIZER' + 'ORGANIZER', + 'CONFERENCE', ]; /** @var array parameters to index */ diff --git a/apps/dav/lib/Migration/BuildCalendarSearchIndexBackgroundJob.php b/apps/dav/lib/Migration/BuildCalendarSearchIndexBackgroundJob.php index fc6680fb11320..baca447fb19d5 100644 --- a/apps/dav/lib/Migration/BuildCalendarSearchIndexBackgroundJob.php +++ b/apps/dav/lib/Migration/BuildCalendarSearchIndexBackgroundJob.php @@ -31,12 +31,13 @@ public function __construct( public function run($argument) { $offset = (int)$argument['offset']; $stopAt = (int)$argument['stopAt']; + $property = $argument['property'] ?? null; $this->logger->info('Building calendar index (' . $offset . '/' . $stopAt . ')'); $startTime = $this->time->getTime(); while (($this->time->getTime() - $startTime) < 15) { - $offset = $this->buildIndex($offset, $stopAt); + $offset = $this->buildIndex($offset, $stopAt, $property); if ($offset >= $stopAt) { break; } @@ -47,7 +48,8 @@ public function run($argument) { } else { $this->jobList->add(self::class, [ 'offset' => $offset, - 'stopAt' => $stopAt + 'stopAt' => $stopAt, + 'property' => $property, ]); $this->logger->info('New building calendar index job scheduled with offset ' . $offset); } @@ -56,11 +58,12 @@ public function run($argument) { /** * @param int $offset * @param int $stopAt + * @param string|null $property only reindex objects whose data contains this property name * @return int */ - private function buildIndex(int $offset, int $stopAt): int { + private function buildIndex(int $offset, int $stopAt, ?string $property): int { $query = $this->db->getQueryBuilder(); - $query->select(['id', 'calendarid', 'uri', 'calendardata']) + $query->select(['id', 'calendarid', 'calendartype', 'uri', 'calendardata']) ->from('calendarobjects') ->where($query->expr()->lte('id', $query->createNamedParameter($stopAt))) ->andWhere($query->expr()->gt('id', $query->createNamedParameter($offset))) @@ -76,7 +79,11 @@ private function buildIndex(int $offset, int $stopAt): int { $calendarData = stream_get_contents($calendarData); } - $this->calDavBackend->updateProperties($row['calendarid'], $row['uri'], $calendarData); + if ($property !== null && stripos($calendarData, $property) === false) { + continue; + } + + $this->calDavBackend->updateProperties($row['calendarid'], $row['uri'], $calendarData, (int)$row['calendartype']); } return $offset; diff --git a/apps/dav/lib/Migration/Version3000Date20261112000000.php b/apps/dav/lib/Migration/Version3000Date20261112000000.php new file mode 100644 index 0000000000000..3b0f472622863 --- /dev/null +++ b/apps/dav/lib/Migration/Version3000Date20261112000000.php @@ -0,0 +1,44 @@ +db->getQueryBuilder(); + $query->select($query->func()->max('id')) + ->from('calendarobjects'); + $result = $query->executeQuery(); + $maxId = (int)$result->fetchOne(); + $result->closeCursor(); + + $this->jobList->add(BuildCalendarSearchIndexBackgroundJob::class, [ + 'offset' => 0, + 'stopAt' => $maxId, + 'property' => 'CONFERENCE', + ]); + } +} diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php index e8aa31a6f44f6..f445053587a11 100644 --- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php @@ -20,6 +20,7 @@ use OCA\DAV\DAV\Sharing\Plugin as SharingPlugin; use OCA\DAV\Events\CalendarDeletedEvent; use OCA\DAV\Exception\UidConflict; +use OCP\Calendar\ICalendarQuery; use OCP\IConfig; use OCP\IL10N; use OCP\Log\Audit\CriticalActionPerformedEvent; @@ -1291,6 +1292,43 @@ public static function searchDataProvider(): array { ]; } + public function testSearchConference(): void { + $calendarId = $this->createTestCalendar(); + + $uri = static::getUniqueID('calobj'); + $calData = <<backend->createCalendarObject($calendarId, $uri, $calData); + + $calendarInfo = [ + 'id' => $calendarId, + 'principaluri' => 'user1', + '{http://owncloud.org/ns}owner-principal' => 'user1', + ]; + + $this->assertCount(0, $this->backend->search($calendarInfo, '/call/', ['LOCATION'], [], null, null)); + $result = $this->backend->search($calendarInfo, '/call/', [ICalendarQuery::SEARCH_PROPERTY_CONFERENCE], [], null, null); + $this->assertCount(1, $result); + $this->assertSame($uri, $result[0]['uri']); + $this->assertSame('https://cloud.example.com/call/abc123', $result[0]['objects'][0]['CONFERENCE'][0][0]); + } + public function testSameUriSameIdForDifferentCalendarTypes(): void { $calendarId = $this->createTestCalendar(); $subscriptionId = $this->createTestSubscription(); diff --git a/lib/public/Calendar/ICalendarQuery.php b/lib/public/Calendar/ICalendarQuery.php index c927fc42efab9..4157f3ea20581 100644 --- a/lib/public/Calendar/ICalendarQuery.php +++ b/lib/public/Calendar/ICalendarQuery.php @@ -67,6 +67,11 @@ interface ICalendarQuery { */ public const SEARCH_PROPERTY_ORGANIZER = 'ORGANIZER'; + /** + * @since 36.0.0 + */ + public const SEARCH_PROPERTY_CONFERENCE = 'CONFERENCE'; + /** * Limit the results to the calendar uri(s) *