From c16f8a9a132cc666c5fe387a3d7946d54f8e15aa Mon Sep 17 00:00:00 2001 From: Henry Stern Date: Sun, 21 Jun 2026 08:31:25 -0300 Subject: [PATCH] caldav: decode inline calendar-data in SyncCollection responses SyncCollection already requests calendar-data via the query's CompRequest, but only the ETag and last-modified props were decoded, so a caller had to follow every sync with a multiget even when the server (e.g. Radicale, SOGo) returned the calendar object inline in the sync-collection response. Decode the calendar-data prop into CalendarObject.Data when it is present; when the server omits it, Data is left nil and the caller fetches it with a multiget as before. Backward compatible. Signed-off-by: Henry Stern Assisted-by: Claude (Anthropic) --- caldav/client.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/caldav/client.go b/caldav/client.go index 0c6493d..91d7c65 100644 --- a/caldav/client.go +++ b/caldav/client.go @@ -515,6 +515,22 @@ func (c *Client) SyncCollection(ctx context.Context, path string, query *SyncQue ModTime: time.Time(getLastMod.LastModified), ETag: string(getETag.ETag), } + + // Many servers return the calendar-data inline in the sync-collection + // response (the query already requests it via CompRequest); decode it so + // the caller need not follow up with a multiget. When the server omits the + // data, Data is left nil and the caller fetches it as before. + var calData calendarDataResp + if err := resp.DecodeProp(&calData); err == nil { + cal, err := ical.NewDecoder(bytes.NewReader(calData.Data)).Decode() + if err != nil { + return nil, err + } + o.Data = cal + } else if !internal.IsNotFound(err) { + return nil, err + } + ret.Updated = append(ret.Updated, o) }