From 2447f84e2b56067a30d9689a332f7fa52ea085b3 Mon Sep 17 00:00:00 2001 From: konrad Date: Sat, 16 Jan 2021 14:37:35 +0000 Subject: [PATCH] Fix /dav/principals/*/ throwing a server error when accessed with GET instead of PROPFIND (#769) Co-authored-by: kolaente Reviewed-on: https://kolaente.dev/vikunja/api/pulls/769 Co-authored-by: konrad Co-committed-by: konrad --- pkg/routes/caldav/listStorageProvider.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/routes/caldav/listStorageProvider.go b/pkg/routes/caldav/listStorageProvider.go index f65a41be24..f1e741102c 100644 --- a/pkg/routes/caldav/listStorageProvider.go +++ b/pkg/routes/caldav/listStorageProvider.go @@ -397,6 +397,11 @@ func (vlra *VikunjaListResourceAdapter) CalculateEtag() string { if vlra.task != nil { return `"` + strconv.FormatInt(vlra.task.ID, 10) + `-` + strconv.FormatInt(vlra.task.Updated.Unix(), 10) + `"` } + + if vlra.list == nil { + return "" + } + // This also returns the etag of the list, and not of the task, // which becomes problematic because the client uses this etag (= the one from the list) to make // Requests to update a task. These do not match and thus updating a task fails. @@ -439,6 +444,10 @@ func (vcls *VikunjaCaldavListStorage) getListRessource(isCollection bool) (rr Vi s := db.NewSession() defer s.Close() + if vcls.list == nil { + return + } + can, _, err := vcls.list.CanRead(s, vcls.user) if err != nil { _ = s.Rollback()