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
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 @@ -388,6 +388,7 @@
'OCA\\DAV\\Migration\\Version1031Date20240610134258' => $baseDir . '/../lib/Migration/Version1031Date20240610134258.php',
'OCA\\DAV\\Migration\\Version1034Date20250605132605' => $baseDir . '/../lib/Migration/Version1034Date20250605132605.php',
'OCA\\DAV\\Migration\\Version1034Date20250813093701' => $baseDir . '/../lib/Migration/Version1034Date20250813093701.php',
'OCA\\DAV\\Migration\\Version1035Date20260302000000' => $baseDir . '/../lib/Migration/Version1035Date20260302000000.php',
'OCA\\DAV\\Migration\\Version1036Date20251202000000' => $baseDir . '/../lib/Migration/Version1036Date20251202000000.php',
'OCA\\DAV\\Model\\ExampleEvent' => $baseDir . '/../lib/Model/ExampleEvent.php',
'OCA\\DAV\\Paginate\\LimitedCopyIterator' => $baseDir . '/../lib/Paginate/LimitedCopyIterator.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 @@ -403,6 +403,7 @@ class ComposerStaticInitDAV
'OCA\\DAV\\Migration\\Version1031Date20240610134258' => __DIR__ . '/..' . '/../lib/Migration/Version1031Date20240610134258.php',
'OCA\\DAV\\Migration\\Version1034Date20250605132605' => __DIR__ . '/..' . '/../lib/Migration/Version1034Date20250605132605.php',
'OCA\\DAV\\Migration\\Version1034Date20250813093701' => __DIR__ . '/..' . '/../lib/Migration/Version1034Date20250813093701.php',
'OCA\\DAV\\Migration\\Version1035Date20260302000000' => __DIR__ . '/..' . '/../lib/Migration/Version1035Date20260302000000.php',
'OCA\\DAV\\Migration\\Version1036Date20251202000000' => __DIR__ . '/..' . '/../lib/Migration/Version1036Date20251202000000.php',
'OCA\\DAV\\Model\\ExampleEvent' => __DIR__ . '/..' . '/../lib/Model/ExampleEvent.php',
'OCA\\DAV\\Paginate\\LimitedCopyIterator' => __DIR__ . '/..' . '/../lib/Paginate/LimitedCopyIterator.php',
Expand Down
2 changes: 2 additions & 0 deletions apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
'{http://apple.com/ns/ical/}calendar-order' => ['calendarorder', 'int'],
'{http://apple.com/ns/ical/}calendar-color' => ['calendarcolor', 'string'],
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}deleted-at' => ['deleted_at', 'int'],
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}default-alarm' => ['default_alarm', 'string'],
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}default-alarm' => ['default_alarm', 'string'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need the NS_OWNCLOUD

];

/**
Expand Down
1 change: 1 addition & 0 deletions apps/dav/lib/DAV/CustomPropertiesBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class CustomPropertiesBackend implements BackendInterface {
private const ALLOWED_NC_PROPERTIES = [
'{http://owncloud.org/ns}calendar-enabled',
'{http://owncloud.org/ns}enabled',
'{http://owncloud.org/ns}default-alarm',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should only be required if you need to save the settings in the oc_properties table, since you are doing a custom mapping to the oc_calendars table, pretty sure this is not needed

];

/**
Expand Down
39 changes: 39 additions & 0 deletions apps/dav/lib/Migration/Version1037Date20260302000000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?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\DB\ISchemaWrapper;
use OCP\DB\Types;
use OCP\Migration\Attributes\AddColumn;
use OCP\Migration\Attributes\ColumnType;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

#[AddColumn(table: 'calendars', name: 'default_alarm', type: ColumnType::STRING)]
class Version1037Date20260302000000 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

$calendarsTable = $schema->getTable('calendars');

if (!$calendarsTable->hasColumn('default_alarm')) {
$calendarsTable->addColumn('default_alarm', Types::STRING, [
Copy link
Contributor

@SebastianKrupinski SebastianKrupinski Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to you tests bellow the setting is an integer there for the field should be an integer also, make sure its a SINGED int, so that both positive and negative numbers work. Also I would allow null, so that null means not set, a positive int means alarm after the start and a negative means before the start

'notnull' => false,
'length' => 10,
'default' => null,
]);
}

return $schema;
}
}

39 changes: 39 additions & 0 deletions apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1881,4 +1881,43 @@ public function testUnshare(): void {
);

}

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

// Test setting default alarm property to 15 minutes before (-900 seconds)
$patch = new PropPatch([
'{http://nextcloud.com/ns}default-alarm' => '-900'
]);
$this->backend->updateCalendar($calendarId, $patch);
$patch->commit();

// Verify the property was set
$calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
$this->assertCount(1, $calendars);
$this->assertEquals('-900', $calendars[0]['{http://nextcloud.com/ns}default-alarm']);

// Test updating to a different value (1 day before = -86400 seconds)
$patch = new PropPatch([
'{http://nextcloud.com/ns}default-alarm' => '-86400'
]);
$this->backend->updateCalendar($calendarId, $patch);
$patch->commit();

$calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
$this->assertEquals('-86400', $calendars[0]['{http://nextcloud.com/ns}default-alarm']);

// Test setting to "none"
$patch = new PropPatch([
'{http://nextcloud.com/ns}default-alarm' => 'none'
]);
$this->backend->updateCalendar($calendarId, $patch);
$patch->commit();

$calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
$this->assertEquals('none', $calendars[0]['{http://nextcloud.com/ns}default-alarm']);

// Clean up
$this->backend->deleteCalendar($calendars[0]['id'], true);
}
}
Loading