fix(caldav): do not assume the first element is the VTODO component

Cherry-Picked from https://github.com/go-vikunja/vikunja/pull/748#issuecomment-3649092134
This commit is contained in:
kolaente
2025-12-13 15:30:22 +01:00
parent 5a907c7a48
commit 62799c129b

View File

@@ -274,8 +274,14 @@ func ParseTaskFromVTODO(content string) (vTask *models.Task, err error) {
if len(parsed.Components) == 0 {
return nil, errors.New("VTODO element does seem not contain any components")
}
vTodo, ok := parsed.Components[0].(*ics.VTodo)
if !ok {
var vTodo *ics.VTodo
for _, comp := range parsed.Components {
if todo, ok := comp.(*ics.VTodo); ok {
vTodo = todo
break
}
}
if vTodo == nil {
return nil, errors.New("VTODO element not found")
}
// We put the vTodo details in a map to be able to handle them more easily