carddav: add max-resource-size to serve

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

View File

@ -5,9 +5,10 @@ import (
) )
type AddressBook struct { type AddressBook struct {
Href string Href string
Name string Name string
Description string Description string
MaxResourceSize int64
} }
type AddressBookQuery struct { type AddressBookQuery struct {

View File

@ -18,6 +18,8 @@ var (
addressBookSupportedAddressData = xml.Name{namespace, "addressbook-supported-address-data"} addressBookSupportedAddressData = xml.Name{namespace, "addressbook-supported-address-data"}
addressDataName = xml.Name{namespace, "address-data"} addressDataName = xml.Name{namespace, "address-data"}
maxResourceSizeName = xml.Name{namespace, "max-resource-size"}
) )
type addressbookHomeSet struct { type addressbookHomeSet struct {
@ -42,6 +44,12 @@ type addressDataType struct {
Version string `xml:"version,attr"` Version string `xml:"version,attr"`
} }
// https://tools.ietf.org/html/rfc6352#section-6.2.3
type maxResourceSize struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:carddav max-resource-size"`
Size int64 `xml:",chardata"`
}
// https://tools.ietf.org/html/rfc6352#section-10.3 // https://tools.ietf.org/html/rfc6352#section-10.3
type addressbookQuery struct { type addressbookQuery struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:carddav addressbook-query"` XMLName xml.Name `xml:"urn:ietf:params:xml:ns:carddav addressbook-query"`

View File

@ -219,7 +219,13 @@ func (b *backend) propfindAddressBook(propfind *internal.Propfind, ab *AddressBo
}, },
}, nil }, nil
}, },
// TODO: addressbook-max-resource-size, addressbook-home-set // TODO: addressbook-home-set
}
if ab.MaxResourceSize > 0 {
props[maxResourceSizeName] = func(*internal.RawXMLValue) (interface{}, error) {
return &maxResourceSize{Size: ab.MaxResourceSize}, nil
}
} }
return internal.NewPropfindResponse("/", propfind, props) return internal.NewPropfindResponse("/", propfind, props)