Calendar gains CTag (CS:getctag), SyncToken (DAV:sync-token) and
Transparent (CALDAV:schedule-calendar-transp). Three optional Backend
interfaces, checked with type assertions:
- SyncBackend answers the sync-collection REPORT (RFC 6578) and adds
DAV:supported-report-set to calendars. ErrInvalidSyncToken gives 403
with DAV:valid-sync-token.
- PrincipalBackend serves calendar-user-address-set, schedule-inbox-URL
and schedule-outbox-URL on the principal, and the inbox and outbox
collections themselves (RFC 6638 section 2).
- FreeBusyBackend answers a VFREEBUSY POST to the outbox with a
schedule-response (RFC 6638 section 10.3), and adds
calendar-auto-schedule to the DAV header.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Read the calendar-color property in the http://apple.com/ns/ical/
namespace in FindCalendar and FindCalendars, and report it in PROPFIND
responses when it is set, the same way as calendar-description.
QueryCalendar and MultiGetCalendar returned no objects at all when the
calendar-data of one of them failed to parse. Skip that object instead
and report its error, with its href, in the returned error, like
multistatus errors since 71ae569.
PutCalendarObject and PutAddressObject sent no conditional request
headers, so a client could not perform an optimistic-concurrency write
(overwrite only if the resource still carries an expected ETag). Add an
options parameter to both, reusing the existing server-side
PutCalendarObjectOptions / PutAddressObjectOptions types so the client
and Backend interface mirror each other. A nil opts preserves the prior
unconditional behaviour; a non-nil opts sets If-Match / If-None-Match.
Signed-off-by: Henry Stern <henry@stern.ca>
Assisted-by: Claude Opus 4.8 <noreply@anthropic.com>
Closes: https://github.com/emersion/go-webdav/issues/130
SyncCollection already requests calendar-data via the query's CompRequest, but
only the ETag and last-modified props were decoded, so a caller had to follow
every sync with a multiget even when the server (e.g. Radicale, SOGo) returned
the calendar object inline in the sync-collection response.
Decode the calendar-data prop into CalendarObject.Data when it is present; when
the server omits it, Data is left nil and the caller fetches it with a multiget
as before. Backward compatible.
Signed-off-by: Henry Stern <henry@stern.ca>
Assisted-by: Claude (Anthropic) <noreply@anthropic.com>
The server hard-coded DAV:read + DAV:write in current-user-privilege-set for
every collection (with a TODO). Add a ReadOnly field to Calendar and AddressBook
that the backend sets per request; report DAV:write only when it is false, so
clients (e.g. DAVx5, Apple) correctly mark read-only collections. Default
(false) keeps the previous read-write behavior.
This change adds FindCalendar function to the caldav client. It can be
used to get calendar information without loading all the events, once the
path of the calendar is known.
NewPropFindResponse uses callbacks to lazily build the response.
However, some props are static: they don't require any processing
to generate. Add a small helper to reduce boilerplate a bit.
Both the displayname and the description can be absent for both
calendars and address books. If this is the case they should not show up
in PROPFIND responses as empty string.
It seems like e.g. Apples reminders likes to send `PropPatch`, and
currently this just fills up my logs because of the panic. I thought it
would be better to signal that this isn't supported yet, which should
hopefully make it easier to dig through the logs.
Matches on open time ranges (i.e. no end date) were not properly
handled, as `end` is simply the zero time, which confuses the
`.Before()` and `.After()` logic employed here.
This commit fixes that by adding the appropriate `.IsZero()` checks and
also adds a test case.
The current behavior unfortunately broke compatibility with DAVx5, which
by default queries only events less than 90 days ago (by using an open
time range).
It seems like the Reminders app in iOS/macOS does this request as
the first thing when setting up an account, so it seems reasonable to
handle it for us.
This just returns the most basic current-user-principal now, but that
should hopefully be enough to continue the process.
I started using this project to export tasks over CalDav, more
specifically to Reminders on iOS/macOS. I quickly realized that
even if you specify that `SupportedComponentSet` contains `VTODO`, that
isn't reflected properly when doing the `PROPFIND`.
This patch should fix that, while keeping the behaviour of defaulting to
`VEVENT` for propfind. Also added some tests to make sure that I didn't
break anything (Which I hope I didn't 😅).
This is done properly in the carddav and caldav packages, but the custom
function does not know what the user intends to serve, so it must be
passed in from the user. Without this, certain clients (e.g. DAVx5)
will be unable to discover endpoints served this way.
Also slightly extend the supported methods returned on OPTIONS requests.
REPORT is properly supported, the others are mostly for not giving
clients the impression that the resources are read-only.
The `If-Match` and `If-None-Match` conditional headers can have either a
wildcard or a (quoted) ETag as value. However, the ETag _could_ be a
literal `*`, so care must be taken to allow these cases to be
distinguished. The values of these headers have to be handled by the
backend, so export a type that facilitates working with these values.
The match helper will now properly return recurring events if any of
their recurrences fall into the queried time range. A test for this was
added as well.
See https://www.rfc-editor.org/errata/eid4164
The original RFC's appendix was missing a part of the calendar data used
in the examples. This will become relevant when adding tests for
retrieving recurring events.
This is not yet complete (see TODOs in code), but basic filtering of a
list of CaledarObjects works.
Includes test data from the RFC, which allows to use the RFCs examples
as test cases.
Allow the backend to provide a value for the `getcontentlength` property
as described in [RFC 2518 section 13.4][1].
The implementation treats is as optional, allthough it is a required
property per RFC. Most clients do perfectly fine without it, though.
Properly setting this in the backend makes the CalDAV collection
listable with clients that do require it, e.g. cadaver.
[1]: https://datatracker.ietf.org/doc/html/rfc2518#section-13.4
CalDAV imposes a set of constraints on iCal Calendar objects. They are
spelled out in RFC 4791, section 4.1 [1]. Add an exported function to
validate a calendar according to those constraints, and return data that
is necessary for further CalDAV processing and which can only be
extracted if the calendar meets these constraints.
[1]: https://datatracker.ietf.org/doc/html/rfc4791#section-4.1