caldav: add supported-calendar-component-set field

This commit is contained in:
Konstantinos Koukas 2022-04-12 10:18:59 +03:00 committed by Simon Ser
parent 6401d9ed45
commit 25dfbaf95e
2 changed files with 21 additions and 8 deletions

View File

@ -10,10 +10,11 @@ import (
) )
type Calendar struct { type Calendar struct {
Path string Path string
Name string Name string
Description string Description string
MaxResourceSize int64 MaxResourceSize int64
SupportedComponentSet []string
} }
type CalendarCompRequest struct { type CalendarCompRequest struct {

View File

@ -55,6 +55,7 @@ func (c *Client) FindCalendars(calendarHomeSet string) ([]Calendar, error) {
internal.DisplayNameName, internal.DisplayNameName,
calendarDescriptionName, calendarDescriptionName,
maxResourceSizeName, maxResourceSizeName,
supportedCalendarComponentSetName,
) )
ms, err := c.ic.Propfind(calendarHomeSet, internal.DepthOne, propfind) ms, err := c.ic.Propfind(calendarHomeSet, internal.DepthOne, propfind)
if err != nil { if err != nil {
@ -94,11 +95,22 @@ func (c *Client) FindCalendars(calendarHomeSet string) ([]Calendar, error) {
return nil, fmt.Errorf("carddav: max-resource-size must be a positive integer") return nil, fmt.Errorf("carddav: max-resource-size must be a positive integer")
} }
var supportedCompSet supportedCalendarComponentSet
if err := resp.DecodeProp(&supportedCompSet); err != nil && !internal.IsNotFound(err) {
return nil, err
}
compNames := make([]string, 0, len(supportedCompSet.Comp))
for _, comp := range supportedCompSet.Comp {
compNames = append(compNames, comp.Name)
}
l = append(l, Calendar{ l = append(l, Calendar{
Path: path, Path: path,
Name: dispName.Name, Name: dispName.Name,
Description: desc.Description, Description: desc.Description,
MaxResourceSize: maxResSize.Size, MaxResourceSize: maxResSize.Size,
SupportedComponentSet: compNames,
}) })
} }