Skip to content

Commit 938554c

Browse files
committed
feat: add default reminder setting caldav
Signed-off-by: Grigory Vodyanov <scratchx@gmx.com>
1 parent 2613f32 commit 938554c

6 files changed

Lines changed: 89 additions & 8 deletions

File tree

apps/dav/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@
389389
'OCA\\DAV\\Migration\\Version1034Date20250605132605' => $baseDir . '/../lib/Migration/Version1034Date20250605132605.php',
390390
'OCA\\DAV\\Migration\\Version1034Date20250813093701' => $baseDir . '/../lib/Migration/Version1034Date20250813093701.php',
391391
'OCA\\DAV\\Migration\\Version1036Date20251202000000' => $baseDir . '/../lib/Migration/Version1036Date20251202000000.php',
392+
'OCA\\DAV\\Migration\\Version1037Date20260302000000' => $baseDir . '/../lib/Migration/Version1037Date20260302000000.php',
392393
'OCA\\DAV\\Model\\ExampleEvent' => $baseDir . '/../lib/Model/ExampleEvent.php',
393394
'OCA\\DAV\\Paginate\\LimitedCopyIterator' => $baseDir . '/../lib/Paginate/LimitedCopyIterator.php',
394395
'OCA\\DAV\\Paginate\\PaginateCache' => $baseDir . '/../lib/Paginate/PaginateCache.php',

apps/dav/composer/composer/autoload_static.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
class ComposerStaticInitDAV
88
{
99
public static $prefixLengthsPsr4 = array (
10-
'O' =>
10+
'O' =>
1111
array (
1212
'OCA\\DAV\\' => 8,
1313
),
1414
);
1515

1616
public static $prefixDirsPsr4 = array (
17-
'OCA\\DAV\\' =>
17+
'OCA\\DAV\\' =>
1818
array (
1919
0 => __DIR__ . '/..' . '/../lib',
2020
),
@@ -404,6 +404,7 @@ class ComposerStaticInitDAV
404404
'OCA\\DAV\\Migration\\Version1034Date20250605132605' => __DIR__ . '/..' . '/../lib/Migration/Version1034Date20250605132605.php',
405405
'OCA\\DAV\\Migration\\Version1034Date20250813093701' => __DIR__ . '/..' . '/../lib/Migration/Version1034Date20250813093701.php',
406406
'OCA\\DAV\\Migration\\Version1036Date20251202000000' => __DIR__ . '/..' . '/../lib/Migration/Version1036Date20251202000000.php',
407+
'OCA\\DAV\\Migration\\Version1037Date20260302000000' => __DIR__ . '/..' . '/../lib/Migration/Version1037Date20260302000000.php',
407408
'OCA\\DAV\\Model\\ExampleEvent' => __DIR__ . '/..' . '/../lib/Model/ExampleEvent.php',
408409
'OCA\\DAV\\Paginate\\LimitedCopyIterator' => __DIR__ . '/..' . '/../lib/Paginate/LimitedCopyIterator.php',
409410
'OCA\\DAV\\Paginate\\PaginateCache' => __DIR__ . '/..' . '/../lib/Paginate/PaginateCache.php',

apps/dav/lib/CalDAV/CalDavBackend.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
151151
'{http://apple.com/ns/ical/}calendar-order' => ['calendarorder', 'int'],
152152
'{http://apple.com/ns/ical/}calendar-color' => ['calendarcolor', 'string'],
153153
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}deleted-at' => ['deleted_at', 'int'],
154+
'{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}default-alarm' => ['default_alarm', 'string'],
154155
];
155156

156157
/**
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace OCA\DAV\Migration;
11+
12+
use Closure;
13+
use OCP\DB\ISchemaWrapper;
14+
use OCP\DB\Types;
15+
use OCP\Migration\Attributes\AddColumn;
16+
use OCP\Migration\Attributes\ColumnType;
17+
use OCP\Migration\IOutput;
18+
use OCP\Migration\SimpleMigrationStep;
19+
20+
#[AddColumn(table: 'calendars', name: 'default_alarm', type: ColumnType::STRING)]
21+
class Version1037Date20260302000000 extends SimpleMigrationStep {
22+
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
23+
/** @var ISchemaWrapper $schema */
24+
$schema = $schemaClosure();
25+
26+
$calendarsTable = $schema->getTable('calendars');
27+
28+
if (!$calendarsTable->hasColumn('default_alarm')) {
29+
$calendarsTable->addColumn('default_alarm', Types::INTEGER, [
30+
'notnull' => false,
31+
'length' => 10,
32+
'default' => null,
33+
]);
34+
}
35+
36+
return $schema;
37+
}
38+
}
39+

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,4 +1881,43 @@ public function testUnshare(): void {
18811881
);
18821882

18831883
}
1884+
1885+
public function testDefaultAlarmProperty(): void {
1886+
$calendarId = $this->createTestCalendar();
1887+
1888+
// Test setting default alarm property to 15 minutes before (-900 seconds)
1889+
$patch = new PropPatch([
1890+
'{http://nextcloud.com/ns}default-alarm' => '-900'
1891+
]);
1892+
$this->backend->updateCalendar($calendarId, $patch);
1893+
$patch->commit();
1894+
1895+
// Verify the property was set
1896+
$calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
1897+
$this->assertCount(1, $calendars);
1898+
$this->assertEquals('-900', $calendars[0]['{http://nextcloud.com/ns}default-alarm']);
1899+
1900+
// Test updating to a different value (1 day before = -86400 seconds)
1901+
$patch = new PropPatch([
1902+
'{http://nextcloud.com/ns}default-alarm' => '-86400'
1903+
]);
1904+
$this->backend->updateCalendar($calendarId, $patch);
1905+
$patch->commit();
1906+
1907+
$calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
1908+
$this->assertEquals('-86400', $calendars[0]['{http://nextcloud.com/ns}default-alarm']);
1909+
1910+
// Test setting to "none"
1911+
$patch = new PropPatch([
1912+
'{http://nextcloud.com/ns}default-alarm' => 'none'
1913+
]);
1914+
$this->backend->updateCalendar($calendarId, $patch);
1915+
$patch->commit();
1916+
1917+
$calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
1918+
$this->assertEquals('none', $calendars[0]['{http://nextcloud.com/ns}default-alarm']);
1919+
1920+
// Clean up
1921+
$this->backend->deleteCalendar($calendars[0]['id'], true);
1922+
}
18841923
}

lib/composer/composer/autoload_static.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,32 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
1111
);
1212

1313
public static $prefixLengthsPsr4 = array (
14-
'O' =>
14+
'O' =>
1515
array (
1616
'OC\\Core\\' => 8,
1717
'OC\\' => 3,
1818
'OCP\\' => 4,
1919
),
20-
'N' =>
20+
'N' =>
2121
array (
2222
'NCU\\' => 4,
2323
),
2424
);
2525

2626
public static $prefixDirsPsr4 = array (
27-
'OC\\Core\\' =>
27+
'OC\\Core\\' =>
2828
array (
2929
0 => __DIR__ . '/../../..' . '/core',
3030
),
31-
'OC\\' =>
31+
'OC\\' =>
3232
array (
3333
0 => __DIR__ . '/../../..' . '/lib/private',
3434
),
35-
'OCP\\' =>
35+
'OCP\\' =>
3636
array (
3737
0 => __DIR__ . '/../../..' . '/lib/public',
3838
),
39-
'NCU\\' =>
39+
'NCU\\' =>
4040
array (
4141
0 => __DIR__ . '/../../..' . '/lib/unstable',
4242
),

0 commit comments

Comments
 (0)