Skip to content

Commit df6ecfb

Browse files
committed
fix(dav): detect added and removed birthday reminders
The trigger was only compared when both the existing and the new birthday event had an alarm, so enabling or disabling the reminder offset never updated existing events. Compare the triggers directly and mention the reminder update in the repair step name. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent adae113 commit df6ecfb

4 files changed

Lines changed: 14 additions & 5 deletions

File tree

‎apps/dav/lib/CalDAV/BirthdayService.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public function syncUser(string $user):void {
286286
* The birthday event is considered changed if either
287287
* - the start date has changed
288288
* - the title has changed
289-
* - the time for the alarm has changed
289+
* - the alarm was added, removed or its trigger has changed
290290
*
291291
* @param string $existingCalendarData
292292
* @param VCalendar $newCalendarData
@@ -303,7 +303,7 @@ public function birthdayEvenChanged(string $existingCalendarData,
303303
return (
304304
$newCalendarData->VEVENT->DTSTART->getValue() !== $existingBirthday->VEVENT->DTSTART->getValue()
305305
|| $newCalendarData->VEVENT->SUMMARY->getValue() !== $existingBirthday->VEVENT->SUMMARY->getValue()
306-
|| ($newCalendarData->VEVENT->VALARM && $existingBirthday->VEVENT->VALARM && $newCalendarData->VEVENT->VALARM->TRIGGER->getValue() !== $existingBirthday->VEVENT->VALARM->TRIGGER->getValue())
306+
|| $newCalendarData->VEVENT->VALARM?->TRIGGER?->getValue() !== $existingBirthday->VEVENT->VALARM?->TRIGGER?->getValue()
307307
);
308308
}
309309

‎apps/dav/lib/Migration/RegenerateBirthdayCalendars.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(
3232
*/
3333
#[\Override]
3434
public function getName() {
35-
return 'Regenerating birthday calendars to use new icons and fix old birthday events without year';
35+
return 'Regenerating birthday calendars to use new icons, fix old birthday events without year and update reminders';
3636
}
3737

3838
/**

‎apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,19 @@ public static function providesBirthday(): array {
385385
"BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:12345\r\nDTSTAMP:20160218T133704Z\r\nDTSTART;VALUE=DATE:19000101\r\nDTEND;VALUE=DATE:19000102\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:12345's Birthday (1900)\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"],
386386
[true,
387387
"BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:12345\r\nDTSTAMP:20160218T133704Z\r\nDTSTART;VALUE=DATE:19000101\r\nDTEND;VALUE=DATE:19000102\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:12345's Birthday (1900)\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n",
388-
"BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:12345\r\nDTSTAMP:20160218T133704Z\r\nDTSTART;VALUE=DATE:19000102\r\nDTEND;VALUE=DATE:19000102\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:12345's Birthday (1900)\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"]
388+
"BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:12345\r\nDTSTAMP:20160218T133704Z\r\nDTSTART;VALUE=DATE:19000102\r\nDTEND;VALUE=DATE:19000102\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:12345's Birthday (1900)\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"],
389+
'same reminder' => [false, self::birthdayWithReminder('PT9H'), self::birthdayWithReminder('PT9H')],
390+
'changed reminder' => [true, self::birthdayWithReminder('-PT0M'), self::birthdayWithReminder('PT9H')],
391+
'added reminder' => [true, self::birthdayWithReminder(null), self::birthdayWithReminder('PT9H')],
392+
'removed reminder' => [true, self::birthdayWithReminder('-PT0M'), self::birthdayWithReminder(null)],
389393
];
390394
}
391395

396+
private static function birthdayWithReminder(?string $trigger): string {
397+
$alarm = $trigger === null ? '' : "BEGIN:VALARM\r\nTRIGGER;VALUE=DURATION:$trigger\r\nACTION:DISPLAY\r\nDESCRIPTION:12345's Birthday (1900)\r\nEND:VALARM\r\n";
398+
return "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:12345\r\nDTSTAMP:20160218T133704Z\r\nDTSTART;VALUE=DATE:19000101\r\nDTEND;VALUE=DATE:19000102\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:12345's Birthday (1900)\r\nTRANSP:TRANSPARENT\r\n{$alarm}END:VEVENT\r\nEND:VCALENDAR\r\n";
399+
}
400+
392401
public static function providesCardChanges(): array {
393402
return[
394403
['delete'],

‎apps/dav/tests/unit/Migration/RegenerateBirthdayCalendarsTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function setUp(): void {
3333

3434
public function testGetName(): void {
3535
$this->assertEquals(
36-
'Regenerating birthday calendars to use new icons and fix old birthday events without year',
36+
'Regenerating birthday calendars to use new icons, fix old birthday events without year and update reminders',
3737
$this->migration->getName()
3838
);
3939
}

0 commit comments

Comments
 (0)