mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-04-24 22:25:15 +00:00
fix(caldav): return other status codes than 500 when projects are not found (#3065)
This allows CalDav clients to behave properly. In particular, DavX5 will error out on syncing the collections list rather than removing deleted projects from its local cache. Resolves: https://community.vikunja.io/t/deleting-a-project-breaks-caldav/3315/3 Co-authored-by: Janne Heß <janne@hess.ooo> Reviewed-on: https://kolaente.dev/vikunja/vikunja/pulls/3065 Reviewed-by: konrad <k@knt.li> Co-authored-by: das_j <das_j@noreply.kolaente.dev> Co-committed-by: das_j <das_j@noreply.kolaente.dev>
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -46,6 +47,9 @@ func getBasicAuthUserFromContext(c echo.Context) (*user.User, error) {
|
||||
// ProjectHandler returns all tasks from a project
|
||||
func ProjectHandler(c echo.Context) error {
|
||||
project, err := getProjectFromParam(c)
|
||||
if err != nil && models.IsErrProjectDoesNotExist(err) {
|
||||
return c.String(http.StatusNotFound, "Project not found")
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -69,7 +73,8 @@ func ProjectHandler(c echo.Context) error {
|
||||
if vtodo != "" && strings.HasPrefix(vtodo, `BEGIN:VCALENDAR`) {
|
||||
storage.task, err = caldav2.ParseTaskFromVTODO(vtodo)
|
||||
if err != nil {
|
||||
return echo.ErrInternalServerError.SetInternal(err)
|
||||
log.Warningf("[CALDAV] Failed to parse task: %v", err)
|
||||
return models.ErrInvalidData{Message: "Invalid task"}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user