Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/dav/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<name>WebDAV</name>
<summary>WebDAV endpoint</summary>
<description>WebDAV endpoint</description>
<version>3.0.0-dev.2</version>
<version>3.0.0-dev.3</version>
<licence>agpl</licence>
<author>owncloud.org</author>
<namespace>DAV</namespace>
Expand Down
1 change: 1 addition & 0 deletions apps/dav/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions apps/dav/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
'SUMMARY',
'ATTENDEE',
'CONTACT',
'ORGANIZER'
'ORGANIZER',
'CONFERENCE',
];

/** @var array parameters to index */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
}
Expand All @@ -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)))
Expand All @@ -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;
Expand Down
44 changes: 44 additions & 0 deletions apps/dav/lib/Migration/Version3000Date20261112000000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\DAV\Migration;

use Closure;
use OCP\BackgroundJob\IJobList;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
use Override;

/**
* Index the CONFERENCE property of calendar objects stored before it became searchable
*/
class Version3000Date20261112000000 extends SimpleMigrationStep {
public function __construct(
private readonly IDBConnection $db,
private readonly IJobList $jobList,
) {
}

#[Override]
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
$query = $this->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',
]);
}
}
38 changes: 38 additions & 0 deletions apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1291,6 +1292,43 @@ public static function searchDataProvider(): array {
];
}

public function testSearchConference(): void {
$calendarId = $this->createTestCalendar();

$uri = static::getUniqueID('calobj');
$calData = <<<EOD
BEGIN:VCALENDAR
VERSION:2.0
PRODID:Nextcloud Calendar
BEGIN:VEVENT
CREATED;VALUE=DATE-TIME:20130910T125139Z
UID:47d15e3ec8-conference
LAST-MODIFIED;VALUE=DATE-TIME:20130910T125139Z
DTSTAMP;VALUE=DATE-TIME:20130910T125139Z
SUMMARY:Hybrid meeting
LOCATION:Meeting room 2
CONFERENCE;VALUE=URI;FEATURE=AUDIO,VIDEO,CHAT;LABEL=Nextcloud Talk:https://cloud.example.com/call/abc123
DTSTART;VALUE=DATE-TIME:20130912T130000Z
DTEND;VALUE=DATE-TIME:20130912T140000Z
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR
EOD;
$this->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();
Expand Down
5 changes: 5 additions & 0 deletions lib/public/Calendar/ICalendarQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
*
Expand Down
Loading