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 <henry@stern.ca> Assisted-by: Claude (Anthropic) <noreply@anthropic.com>
This commit is contained in:
parent
1901d193ce
commit
c16f8a9a13
@ -515,6 +515,22 @@ func (c *Client) SyncCollection(ctx context.Context, path string, query *SyncQue
|
|||||||
ModTime: time.Time(getLastMod.LastModified),
|
ModTime: time.Time(getLastMod.LastModified),
|
||||||
ETag: string(getETag.ETag),
|
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)
|
ret.Updated = append(ret.Updated, o)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user