feat(tasks): add explicit deletion with DAV tombstones
Build and publish container images / images (push) Successful in 11m42s
Release container images / release (push) Successful in 27s

This commit is contained in:
Anya Tokugawa committed 2026-11-08 18:04:54 +09:00
1 parent dc978231e2
commit 38a4fcf530
15 files changed
+530 -10

No files matched your search

+29 -1
View File
@@ -62,6 +62,12 @@ func taskError(w http.ResponseWriter, err error) {
status, code = 422, "invalid"
case errors.Is(err, store.ErrTaskConflict):
status, code = 412, "conflict"
case errors.Is(err, store.ErrTaskDeleted):
status, code = 410, "deleted"
case errors.Is(err, store.ErrTaskHasChildren):
status, code = 409, "has_children"
case errors.Is(err, store.ErrTaskWorking):
status, code = 409, "working"
case errors.Is(err, store.ErrTaskDAVIdentity):
status, code = 409, "uid_conflict"
case errors.Is(err, store.ErrTaskDAVRelocated):
@@ -323,8 +329,30 @@ func (s *Server) handleTasksAPI(w http.ResponseWriter, r *http.Request) {
writeEventJSON(w, 200, map[string]any{"items": items, "parents": parents, "next": next, "today": today})
return
}
if r.Method == "DELETE" && id != "" {
if !active {
taskError(w, store.ErrAccessDenied)
return
}
tag := r.Header.Get("If-Match")
if tag == "" {
writeEventJSON(w, 428, map[string]string{"error": "precondition"})
return
}
expected, _ := strconv.ParseInt(strings.Trim(tag, `"`), 10, 64)
if expected < 1 || tag != `"`+strconv.FormatInt(expected, 10)+`"` {
taskError(w, store.ErrTaskInvalid)
return
}
if err := s.store.DeleteTask(ctx, domain, actor, id, expected); err != nil {
taskError(w, err)
return
}
w.WriteHeader(http.StatusNoContent)
return
}
if (r.Method != "POST" || id != "") && (r.Method != "PUT" || id == "") {
w.Header().Set("Allow", "GET, POST, PUT")
w.Header().Set("Allow", "GET, POST, PUT, DELETE")
w.WriteHeader(405)
return
}