From 1b6da1639adb22c011b1f6f14a72ddc417c93109 Mon Sep 17 00:00:00 2001 From: Jonathan Liu Date: Sun, 18 Aug 2024 15:07:19 -0700 Subject: [PATCH] Added expand request --- caldav/caldav.go | 6 ++++++ caldav/client.go | 15 ++++++++++++++- caldav/elements.go | 9 ++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/caldav/caldav.go b/caldav/caldav.go index 02705ef..f4862c2 100644 --- a/caldav/caldav.go +++ b/caldav/caldav.go @@ -79,6 +79,12 @@ type CalendarCompRequest struct { AllComps bool Comps []CalendarCompRequest + + Expand *CalendarExpandRequest +} + +type CalendarExpandRequest struct { + Start, End time.Time } type CompFilter struct { diff --git a/caldav/client.go b/caldav/client.go index e19e84c..9071bbd 100644 --- a/caldav/client.go +++ b/caldav/client.go @@ -154,7 +154,9 @@ func encodeCalendarReq(c *CalendarCompRequest) (*internal.Prop, error) { return nil, err } - calDataReq := calendarDataReq{Comp: compReq} + expandReq := encodeExpandRequest(c.Expand) + + calDataReq := calendarDataReq{Comp: compReq, Expand: expandReq} getLastModReq := internal.NewRawXMLElement(internal.GetLastModifiedName, nil, nil) getETagReq := internal.NewRawXMLElement(internal.GetETagName, nil, nil) @@ -175,6 +177,17 @@ func encodeCompFilter(filter *CompFilter) *compFilter { return &encoded } +func encodeExpandRequest(e *CalendarExpandRequest) *expand { + if e == nil { + return nil + } + encoded := expand{ + Start: dateWithUTCTime(e.Start), + End: dateWithUTCTime(e.End), + } + return &encoded +} + func decodeCalendarObjectList(ms *internal.MultiStatus) ([]CalendarObject, error) { addrs := make([]CalendarObject, 0, len(ms.Responses)) for _, resp := range ms.Responses { diff --git a/caldav/elements.go b/caldav/elements.go index 5759f31..aed6050 100644 --- a/caldav/elements.go +++ b/caldav/elements.go @@ -179,7 +179,8 @@ func (t *dateWithUTCTime) MarshalText() ([]byte, error) { type calendarDataReq struct { XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav calendar-data"` Comp *comp `xml:"comp,omitempty"` - // TODO: expand, limit-recurrence-set, limit-freebusy-set + Expand *expand `xml:"expand,omitempty"` + // TODO: limit-recurrence-set, limit-freebusy-set } // https://tools.ietf.org/html/rfc4791#section-9.6.1 @@ -194,6 +195,12 @@ type comp struct { Comp []comp `xml:"comp,omitempty"` } +type expand struct { + XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav expand"` + Start dateWithUTCTime `xml:"start,attr"` + End dateWithUTCTime `xml:"end,attr"` +} + // https://tools.ietf.org/html/rfc4791#section-9.6.4 type prop struct { XMLName xml.Name `xml:"urn:ietf:params:xml:ns:caldav prop"`