fix(task): correctly load tasks by id and uuid in caldav

Partially reverts 1afc72e190
This commit is contained in:
kolaente 2023-03-01 22:18:59 +01:00
parent e8c85562b1
commit 534d04a1db
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 7 additions and 2 deletions

View File

@ -1612,7 +1612,7 @@ func (t *Task) Delete(s *xorm.Session, a web.Auth) (err error) {
// @Router /tasks/{ID} [get]
func (t *Task) ReadOne(s *xorm.Session, a web.Auth) (err error) {
*t, err = GetTaskSimple(s, t)
*t, err = GetTaskByIDSimple(s, t.ID)
if err != nil {
return
}

View File

@ -210,7 +210,7 @@ func (vcls *VikunjaCaldavListStorage) GetResource(rpath string) (*data.Resource,
// save and override the updated unix date to not break any later etag checks
updated := vcls.task.Updated
err := vcls.task.ReadOne(s, vcls.user)
tasks, err := models.GetTasksByUIDs(s, []string{vcls.task.UID}, vcls.user)
if err != nil {
_ = s.Rollback()
if models.IsErrTaskDoesNotExist(err) {
@ -222,6 +222,11 @@ func (vcls *VikunjaCaldavListStorage) GetResource(rpath string) (*data.Resource,
return nil, false, err
}
if len(tasks) < 1 {
return nil, false, errs.ResourceNotFoundError
}
vcls.task = tasks[0]
if updated.Unix() > 0 {
vcls.task.Updated = updated
}