Commit Graph

287 Commits

Author SHA1 Message Date
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
Dan Berglund
46dbba12fe
caldav: return SupportedComponentSet in PROPFIND
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 😅).
2023-07-03 10:47:34 +02:00
Simon Ser
150f74a6f0 Add GitHub issue template 2023-01-04 11:00:51 +01:00
Conrad Hoffmann
0456b28ba3 Support setting capabilities in ServePrincipal()
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.
2022-12-13 15:46:51 +01:00
Conrad Hoffmann
ac9af45270 Dedicated type for conditional match header fields
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.
2022-11-22 11:58:13 +01:00
Conrad Hoffmann
d4d56c2707 carddav: use custom type for context keys 2022-11-16 10:37:40 +01:00
Conrad Hoffmann
5bfd6f54b2 caldav: use same static path layout as carddav 2022-11-16 10:37:40 +01:00
Conrad Hoffmann
54f2a6355b caldav: implement Propfind
It did not handle Depth or requests to calendar components. This brings
the implementation on par with the one CardDAV one.
2022-11-02 19:49:53 +01:00
Conrad Hoffmann
001e5953f7 caldav: support deletion of calendar objects
Has to be implemented by the backend.
2022-11-02 19:49:01 +01:00
Conrad Hoffmann
561012d30f carddav: switch to one static path layout
See #100 for details. Obsoletes #99.
2022-11-02 19:44:42 +01:00
Krystian Chachuła
6f22a649ac caldav: fix validation error when VTIMEZONE is after VEVENT 2022-09-16 09:04:14 +02:00
Conrad Hoffmann
dc63df9058 carddav: evaluate recurrence in match helper
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.
2022-08-31 16:57:42 +02:00
Conrad Hoffmann
58dc8e4982 Update to latest version of go-ical
Needed for handling of recurring events.
2022-08-31 16:57:42 +02:00
Conrad Hoffmann
9adfd95fa9 carddav: run gofmt 2022-08-31 13:53:16 +02:00
Conrad Hoffmann
4264d321a5 caldav: fix match test example from RFC
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.
2022-08-31 10:13:02 +02:00
Conrad Hoffmann
4a3cd0510f carddav: end-to-end test address book discovery
As the implementation evolves, it will be necessary to have more tests
to assert we don't break anything when making changes. This commit
introduces a test setup to test that server and client can handle the
address book discovery with various parameters. The test setup should be
easily extendable to cover even more ground as needed.
2022-07-13 08:45:11 +02:00