carddav: add addressbook-supprted-address-data to server

This commit is contained in:
Simon Ser 2020-01-19 15:00:15 +01:00
parent edfc2804b5
commit 238e72b73e
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 27 additions and 6 deletions

View File

@ -10,11 +10,12 @@ import (
const namespace = "urn:ietf:params:xml:ns:carddav"
var (
addressBookName = xml.Name{namespace, "addressbook"}
addressBookHomeSetName = xml.Name{namespace, "addressbook-home-set"}
addressBookDescriptionName = xml.Name{namespace, "addressbook-description"}
addressBookQueryName = xml.Name{namespace, "addressbook-query"}
addressBookMultigetName = xml.Name{namespace, "addressbook-multiget"}
addressBookName = xml.Name{namespace, "addressbook"}
addressBookHomeSetName = xml.Name{namespace, "addressbook-home-set"}
addressBookDescriptionName = xml.Name{namespace, "addressbook-description"}
addressBookQueryName = xml.Name{namespace, "addressbook-query"}
addressBookMultigetName = xml.Name{namespace, "addressbook-multiget"}
addressBookSupportedAddressData = xml.Name{namespace, "addressbook-supported-address-data"}
addressDataName = xml.Name{namespace, "address-data"}
)
@ -29,6 +30,18 @@ type addressbookDescription struct {
Description string `xml:",chardata"`
}
// https://tools.ietf.org/html/rfc6352#section-6.2.2
type addressbookSupportedAddressData struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:carddav addressbook-supported-address-data"`
Types []addressDataType `xml:"address-data-type"`
}
type addressDataType struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:carddav address-data-type"`
ContentType string `xml:"content-type,attr"`
Version string `xml:"version,attr"`
}
// https://tools.ietf.org/html/rfc6352#section-10.3
type addressbookQuery struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:carddav addressbook-query"`

View File

@ -211,7 +211,15 @@ func (b *backend) propfindAddressBook(propfind *internal.Propfind, ab *AddressBo
addressBookDescriptionName: func(*internal.RawXMLValue) (interface{}, error) {
return &addressbookDescription{Description: ab.Description}, nil
},
// TODO: addressbook-supported-address-data, addressbook-max-resource-size, addressbook-home-set
addressBookSupportedAddressData: func(*internal.RawXMLValue) (interface{}, error) {
return &addressbookSupportedAddressData{
Types: []addressDataType{
{ContentType: vcard.MIMEType, Version: "3.0"},
{ContentType: vcard.MIMEType, Version: "4.0"},
},
}, nil
},
// TODO: addressbook-max-resource-size, addressbook-home-set
}
return internal.NewPropfindResponse("/", propfind, props)