emersion / go-webdav

A Go library for WebDAV, CalDAV and CardDAV
MIT License
314 stars 66 forks source link

carddav: support address book creation/deletion #143

Closed bitfehler closed 7 months ago

bitfehler commented 7 months ago

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, except for the path (e.g. when a client sends a MKCOL request without a body. It is up to the backend to put any desired default values in place. As is, the parsing of the request body still needs some improvements, but correctly handles the most common properties.

Using this as is (in tokidoki), I can successfully create and delete address books using DavX5. The validation is not great yet, but since this touches the interface again, I wanted to make sure early on that this looks like the right approach to you.

emersion commented 7 months ago

Yeah, in general this looks like a good approach to me!

bitfehler commented 7 months ago

Cool, thanks. I added another commit (will squash at the end). It does two things, both of which look slightly ugly to me, so again I'd appreciate your opinion!

  1. The parsing of the <mkcol> element now checks that the <resourcetype> element contains exactly <cDAV: ollection/> and <CAL: calendar>, but it's ugly AF. Is there any better way to do it? I couldn't find one...
  2. You are already adding comments about the empty body thing, so i'll just reply there instead :slightly_smiling_face:
bitfehler commented 7 months ago

I think this is a good start now. Let me know what you think.

emersion commented 7 months ago

FYI, I've made a small adjustment: https://github.com/emersion/go-webdav/commit/fbcd08d64ad28a3f902d9409551237af6f4decf7