Commit Graph

302 Commits

Author SHA1 Message Date
Timo Furrer
002c347f47 caldav: support prop-filter in client requests
This change set adds support for correctly encoding the prop filters
into calendar requests.

Example Request with this change set:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<calendar-query
	xmlns="urn:ietf:params:xml:ns:caldav">
	<prop
		xmlns="DAV:">
		<calendar-data
			xmlns="urn:ietf:params:xml:ns:caldav">
			<comp
				xmlns="urn:ietf:params:xml:ns:caldav" name="VCALENDAR">
				<comp
					xmlns="urn:ietf:params:xml:ns:caldav" name="VEVENT">
					<prop
						xmlns="urn:ietf:params:xml:ns:caldav" name="UID">
					</prop>
					<prop
						xmlns="urn:ietf:params:xml:ns:caldav" name="ATTENDEE">
					</prop>
				</comp>
			</comp>
		</calendar-data>
		<getlastmodified
			xmlns="DAV:">
		</getlastmodified>
		<getetag
			xmlns="DAV:">
		</getetag>
	</prop>
	<filter
		xmlns="urn:ietf:params:xml:ns:caldav">
		<comp-filter
			xmlns="urn:ietf:params:xml:ns:caldav" name="VCALENDAR">
			<comp-filter
				xmlns="urn:ietf:params:xml:ns:caldav" name="VEVENT">
				<prop-filter
					xmlns="urn:ietf:params:xml:ns:caldav" name="UID">
					<text-match
						xmlns="urn:ietf:params:xml:ns:caldav">5bf5ee84-a9cf-4319-9def-437b00e2be8d
					</text-match>
				</prop-filter>
			</comp-filter>
		</comp-filter>
	</filter>
</calendar-query
```
2025-02-21 14:22:01 +01:00
Simon Ser
1b10baf554 ci: check gofmt, split build into separate task, enable -race 2025-02-21 10:52:48 +01:00
Timo Furrer
aba953c3b6 Implement context path discovery for CalDav/CardDav endpoint
This change set implements the "context path" discovery for the
CalDav/CardDav endpoints.

This basically implements the bootstrapping process as defined in
RFC6764 section 6, point 2 and 3.

What's missing in this implementation is the fallback that is described
in point 3, subpoint 3, which says that if the context path discovered
in the TXT RR is not reachable the .well-known URI should be used
instead.

I propose to implement this in a future iteration.
2025-02-21 10:50:48 +01:00
Timo Furrer
172968d292 Fix service name for CalDav/CardDav endpoint discovery
This change set fixes the service names used by the endpoint discovery
for CalDav and CardDav.
2025-02-21 10:50:48 +01:00
Simon Ser
0ae1d1be40 webdav: return 405 when directory already exists for MKCOL 2025-02-18 01:17:34 +01:00
Simon Ser
963b23b8d0 webdav: add support for If-Match/If-None-Match in DELETE 2025-02-14 18:26:04 +01:00
Simon Ser
c1bcf21ad4 webdav: fix ConditionalMatch.MatchETag when resource doesn't exist
Fixes "If-None-Match: *".
2025-02-14 16:49:26 +01:00
Simon Ser
3cc7466ac9 internal: add PropFindValue
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.
2025-01-13 23:00:32 +01:00
Simon Ser
9d778f4072 webdav: add support for If-Match/If-None-Match in FileSystem.Create 2024-12-09 22:31:59 +01:00
Simon Ser
93fee5bcf0 webdav: don't leave a partially uploaded file behind on error 2024-12-09 09:19:16 +01:00
Simon Ser
7f8c17ad71 readme: drop CI badge
The GitHub UI already displays that information.
2024-07-13 15:55:26 +02:00
Thomas Müller
810c51fa2d webdav: PUT response has no body and therefore should not have a content length header 2024-06-06 16:53:57 +02:00
Conrad Hoffmann
21f251fa1d Update go-ical
It's only a dependency update in go-ical, but it allows gettin rid of
rrule-go v.1.7, which is nice.
2024-04-19 16:39:09 +02:00
Thomas Müller
ff8598015d webdav: respond PUT request with 204/No Content in case the file already existed before putting 2024-04-17 15:51:26 +02:00
Thomas Müller
ffd81465fd webdav: FileSystem.Create() returns FileInfo and is used to set PUT response headers 2024-04-17 15:16:35 +02:00
Thomas Müller
948f33c2fc internal: use application/xml instead of text/xml which is deprecated 2024-04-11 17:16:25 +02:00
Thomas Müller
381b8a3cee carddav: add unit test for CardDAV mkcol 2024-04-09 12:55:19 +02:00
Thomas Müller
df447dc627 webdav: change FileSystem.Create to give implementations more control 2024-04-09 12:46:16 +02:00
Thomas Müller
3ed9a4f052 carddav, caldav: add missing headers on PUT
ETag and Last-Modified should be set to the new calendar object or
address object properties.
2024-03-28 11:22:46 +01:00
Conrad Hoffmann
25f1014ef2 internal: no status element in propstat responses
Responses that contain propstat elements do not contain their own
top-level status element, only the status elements inside the propstat
element.

See https://datatracker.ietf.org/doc/html/rfc4918#section-14.24 or any
of the examples for PROPFIND/PROPPATCH, starting e.g. here:
https://datatracker.ietf.org/doc/html/rfc4918#section-9.1.3
2024-02-08 23:12:59 +01:00
Conrad Hoffmann
ad1fe1c5a8 caldav, carddav: displayname and desription are optional
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.
2024-02-08 17:15:04 +01:00
Thomas Müller
0ea114ec79 caldav: add MKCOL support 2024-02-08 17:08:41 +01:00
Simon Ser
20fad80dff carddav: return HTTP 501 error instead of panicing 2024-02-07 17:26:50 +01:00
Dan Berglund
12d8b4bf62 caldav: return proper HTTP 501 instead of panicing
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.
2024-02-07 17:25:57 +01:00
Simon Ser
fbcd08d64a carddav: pass pointer in CreateAddressBook
The struct is a bit too large to pass by value.
2024-02-07 17:24:04 +01:00
Simon Ser
f1d56f2437 internal: add IsRequestEmpty 2024-02-07 17:23:17 +01:00
Conrad Hoffmann
71bd967b43 carddav: support address book creation/deletion
Now that the handling for multiple address books is in place, this
commit adds initial support for creation and deletion of address books.

These operations obviously require support from the backend, so the
interface gains two new methods. All properties of the address book
passed to `CreateAddressBook()` may be unset (e.g. when a client sends a
MKCOL request without a body), except for the path, which is always set.
It is up to the backend to put any desired default values in place.
2024-02-07 17:20:48 +01:00
Simon Ser
80d77a977a webdav: stop using os errors in FileSystem interface
Use NewHTTPError instead.

Closes: https://github.com/emersion/go-webdav/issues/20
2024-02-06 15:23:30 +01:00
Conrad Hoffmann
eaac65215b carddav: support multiple address books
This is the equivalent of #127 (and #140) for CardDAV and finally allows
backends to serve different address books to different users.

While I'm breaking the interface, correct one last instance of
"Addressbook" to "AddressBook" (in `AddressBookHomeSetPath`).
2024-02-02 17:48:22 +01:00
Conrad Hoffmann
e3ba95cd77 caldav: add path to interface QueryCalendarObjects
This was missing for proper multi-calendar support.
2024-02-02 14:28:22 +01:00
Conrad Hoffmann
5b5b542f2f caldav: fix match on open time ranges
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).
2024-02-01 14:36:51 +01:00
Simon Ser
ced348a58f webdav: move ConditionalMatch to webdav.go
It's not an XML element.
2024-01-18 13:37:21 +01:00
Simon Ser
b821d8c1ea webdav: introduce MoveOptions 2024-01-18 13:28:50 +01:00
Simon Ser
790ebfc5f8 webdav: rename MoveAll to Move 2024-01-18 13:28:50 +01:00
Simon Ser
4493704689 webdav: introduce CopyOptions 2024-01-18 13:28:50 +01:00
Simon Ser
b043bbd965 internal/server: handle PROPFIND without body
See RFC 4918 section 9.1.
2024-01-08 14:58:24 +01:00
Simon Ser
75d3041b41 webdav: rename Client.Readdir to ReadDir
This is a more idiomatic name, and we've broken the API already
to add the ctx argument.
2024-01-08 14:35:56 +01:00
Simon Ser
751741d87e webdav: add/improve doc comments 2024-01-08 14:35:19 +01:00
Simon Ser
7e076258d6 caldav: add DiscoverContextURL 2023-12-27 23:16:49 +01:00
Simon Ser
174622c1eb carddav: rename Discover to DiscoverContextURL
This only performs part of the discovery process.
2023-12-27 23:11:51 +01:00
Simon Ser
d033e09835 webdav: add context to FileSystem 2023-12-19 21:29:54 +01:00
Simon Ser
379a418130 Add context for clients 2023-12-19 21:29:37 +01:00
Simon Ser
0e58dbb003 caldav, carddav: take header when populating object
References: https://github.com/emersion/go-webdav/pull/134
2023-12-18 18:18:56 +01:00
Sebastien Binet
7d337ac048 internal: fix always-true interface comparison
This CL corrects the following bug uncovered by staticcheck:

```
  internal/elements.go:148:6: this comparison is always true (SA4023)
    internal/elements.go:146:18: the lhs of the comparison gets its value from here and has a concrete type
```

Signed-off-by: Sebastien Binet <binet@cern.ch>
2023-12-15 15:07:59 +01:00
Simon Ser
dddaf279ed Upgrade dependencies 2023-09-10 14:52:02 +09:00
Simon Ser
fc4ea1aae2 caldav, carddav: drop unnecessary nil check
Closes: https://github.com/emersion/go-webdav/issues/92
2023-08-25 13:35:33 +02:00
Dan Berglund
571eba7c02 caldav: add multi-calendar support 2023-08-21 13:06:59 +02:00
Simon Ser
b46cbafa6f readme: switch back to pkg.go.dev for docs 2023-08-15 08:29:01 +02:00
Simon Ser
0fb0a675ab carddav: handle PROPFIND on root
Same as 7dd64908d2 ("caldav: handle PROPFIND on root") but for
CardDAV.
2023-07-06 12:14:17 +02:00
Dan Berglund
7dd64908d2 caldav: handle PROPFIND on root
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.
2023-07-06 12:12:07 +02:00