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 {
Path string
Name string
Description string
MaxResourceSize int64
Path string
Name string
Description string
MaxResourceSize int64
SupportedComponentSet []string
}
type CalendarCompRequest struct {

View File

@ -55,6 +55,7 @@ func (c *Client) FindCalendars(calendarHomeSet string) ([]Calendar, error) {
internal.DisplayNameName,
calendarDescriptionName,
maxResourceSizeName,
supportedCalendarComponentSetName,
)
ms, err := c.ic.Propfind(calendarHomeSet, internal.DepthOne, propfind)
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")
}
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{
Path: path,
Name: dispName.Name,
Description: desc.Description,
MaxResourceSize: maxResSize.Size,
Path: path,
Name: dispName.Name,
Description: desc.Description,
MaxResourceSize: maxResSize.Size,
SupportedComponentSet: compNames,
})
}