mirror of
https://github.com/1f349/go-webdav.git
synced 2024-12-23 00:34:23 +00:00
carddav: add limit support to addressbook-query
References: https://github.com/emersion/go-webdav/issues/18
This commit is contained in:
parent
70c3bffdf3
commit
94f47fa001
@ -19,10 +19,13 @@ type AddressBook struct {
|
|||||||
type AddressBookQuery struct {
|
type AddressBookQuery struct {
|
||||||
Props []string
|
Props []string
|
||||||
AllProp bool
|
AllProp bool
|
||||||
|
|
||||||
|
Limit int // <= 0 means unlimited
|
||||||
}
|
}
|
||||||
|
|
||||||
type AddressBookMultiGet struct {
|
type AddressBookMultiGet struct {
|
||||||
Paths []string
|
Paths []string
|
||||||
|
|
||||||
Props []string
|
Props []string
|
||||||
AllProp bool
|
AllProp bool
|
||||||
}
|
}
|
||||||
|
@ -215,6 +215,9 @@ func (c *Client) QueryAddressBook(addressBook string, query *AddressBookQuery) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
addressbookQuery := addressbookQuery{Prop: propReq}
|
addressbookQuery := addressbookQuery{Prop: propReq}
|
||||||
|
if query.Limit > 0 {
|
||||||
|
addressbookQuery.Limit = &limit{NResults: uint(query.Limit)}
|
||||||
|
}
|
||||||
|
|
||||||
req, err := c.ic.NewXMLRequest("REPORT", addressBook, &addressbookQuery)
|
req, err := c.ic.NewXMLRequest("REPORT", addressBook, &addressbookQuery)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -80,6 +80,12 @@ func (h *Handler) handleQuery(w http.ResponseWriter, query *addressbookQuery) er
|
|||||||
q.Props = append(q.Props, p.Name)
|
q.Props = append(q.Props, p.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if query.Limit != nil {
|
||||||
|
q.Limit = int(query.Limit.NResults)
|
||||||
|
if q.Limit <= 0 {
|
||||||
|
return internal.ServeMultistatus(w, internal.NewMultistatus())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
aos, err := h.Backend.QueryAddressObjects(&q)
|
aos, err := h.Backend.QueryAddressObjects(&q)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user