Hello @bertrandda ,
I’m having an issue with a CalDAV calendar containing annually recurring birthdays.
Today, I have a birthday that is present in my CalDAV calendar Birthdays, but the event of the day does not appear in Gladys.
The CalDAV connection seems to be working correctly:
Gladys correctly discovers the Birthdays calendar during synchronizations;
other calendars, including Family, work;
I tried disabling/re-enabling the calendar and restarting a synchronization, without success.
Looking at the CalDAV code of Gladys, I noticed that recurring events are developed within a limited time window, including:
const rangeStart = this.dayjs().subtract(1, 'years');
const rangeEnd = this.dayjs().add(2, 'years');
I wonder if the following scenario could occur:
An annual event with an RRULE is synchronized.
Gladys creates its occurrences up to +2 years.
The years pass without modification of the source event.
The ctag of the calendar does not change.
Gladys does not reprocess the recurring event.
The pre-calculated occurrences eventually reach the end of the initially generated window.
Is this scenario possible with the current CalDAV synchronization functionality?
This could explain why a birthday always present on the CalDAV side no longer appears in Gladys several years after its initial import.
If it’s useful to confirm, I can perform tests on my installation, for example, force a complete resynchronization of the calendar and check if the occurrence reappears.
Thanks!
Hi @spenceur ,
Good catch, there is indeed an issue when a recurring event is not updated for a long time.
Here is a PR to fix this
master ← bertrandda:fix/caldav-refresh-recurring-events
ouvert 08:11PM - 05 Oct 26 UTC
### Description
Recurring events are expanded over [now - 1 year, now + 2 yea… rs] when they are synchronized. As the CalDAV sync is incremental (ctag / sync token), an event that is never modified (a birthday for instance) was never expanded again, so its occurrences ran out about 2 years after the import.
Once every 30 days, the recurring events of each CalDAV calendar are now requested with a calendar-query REPORT filtering on the RRULE property, and their occurrences are computed again. If the server rejects this request, every event of the calendar is synchronized instead. The refresh date is kept in the existing calendar last_sync column.
### Related request
https://community.gladysassistant.com/t/caldav-les-occurrences-futures-d-evenements-recurrents-ne-sont-elles-plus-regenerees-apres-un-certain-temps/10680
### Checklist
- [ ] If a forum topic or GitHub issue exists, the description links it (`Forum: https://community.gladysassistant.com/t/...` or `Closes #...`)
- [ ] Tests pass: `cd server && npm run coverage` (Codecov requires 100% coverage on changed lines) and Cypress (`npm run cypress:run`) if the UI changed
- [ ] Linter and prettier pass on both front and server (`npm run eslint`, `npm run prettier`)
- [ ] No undocumented breaking change
## Summary by CodeRabbit
* **New Features**
* Recurring events in CalDAV calendars are refreshed every 30 days, or sooner if they have never been synced. Refreshes can run alongside changes sync.
* **Bug Fixes**
* If a recurring-event refresh is rejected, calendars without a sync token fall back to a full event sync.
* Saved recurring-event occurrences are retained when an updated event cannot be processed or saved.
* Calendars with syncing disabled are skipped, and subscribed web calendars update only when their contents change.
A docker image will be available in the next few minutes to test bertrandda/gladys:caldav