carddav: add address-data to server responses

This commit is contained in:
Simon Ser 2020-01-19 12:08:53 +01:00
parent 4a2a520522
commit 797b2f8fc5
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 11 additions and 2 deletions

View File

@ -15,6 +15,8 @@ var (
addressBookDescriptionName = xml.Name{namespace, "addressbook-description"} addressBookDescriptionName = xml.Name{namespace, "addressbook-description"}
addressBookQueryName = xml.Name{namespace, "addressbook-query"} addressBookQueryName = xml.Name{namespace, "addressbook-query"}
addressBookMultigetName = xml.Name{namespace, "addressbook-multiget"} addressBookMultigetName = xml.Name{namespace, "addressbook-multiget"}
addressDataName = xml.Name{namespace, "address-data"}
) )
type addressbookHomeSet struct { type addressbookHomeSet struct {
@ -74,7 +76,7 @@ type addressDataResp struct {
} }
type reportReq struct { type reportReq struct {
Query *addressbookQuery Query *addressbookQuery
Multiget *addressbookMultiget Multiget *addressbookMultiget
} }

View File

@ -209,8 +209,15 @@ func (b *backend) propfindAddressObject(propfind *internal.Propfind, ao *Address
internal.GetContentTypeName: func(*internal.RawXMLValue) (interface{}, error) { internal.GetContentTypeName: func(*internal.RawXMLValue) (interface{}, error) {
return &internal.GetContentType{Type: vcard.MIMEType}, nil return &internal.GetContentType{Type: vcard.MIMEType}, nil
}, },
addressBookDataName: func(*internal.RawXMLValue) (interface{}, error) {
var buf bytes.Buffer
if err := vcard.NewEncoder(&buf).Encode(ao.Card); err != nil {
return nil, err
}
return &addressDataResp{Data: buf.Bytes()}, nil
},
// TODO: getlastmodified, getetag // TODO: getlastmodified, getetag
// TODO: address-data
} }
return internal.NewPropfindResponse(ao.Href, propfind, props) return internal.NewPropfindResponse(ao.Href, propfind, props)