Add cancellation reason tracking with user/system codes and UI

This commit is contained in:
2026-07-08 17:31:22 -04:00
parent 3c1bbce9e7
commit 69c4898a56
9 changed files with 137 additions and 32 deletions
+15 -1
View File
@@ -2,10 +2,12 @@ package api
import (
"database/sql"
"encoding/json"
"fmt"
"net/http"
"os"
"strconv"
"strings"
"time"
"github.com/go-chi/chi/v5"
@@ -109,11 +111,23 @@ func (h *JobHandler) Cancel(w http.ResponseWriter, r *http.Request) {
return
}
var body struct {
Reason string `json:"reason"`
}
if r.Body != nil && r.ContentLength > 0 {
_ = json.NewDecoder(r.Body).Decode(&body)
}
reason := strings.TrimSpace(body.Reason)
if reason == "" {
reason = "Job was cancelled by user"
}
if h.engine != nil {
h.engine.Cancel(id, j.SyncPairID)
h.engine.Cancel(id, j.SyncPairID, true)
}
repo.UpdateStatus(id, "cancelled")
repo.SetError(id, "cancelled_user", reason)
writeJSON(w, map[string]string{"status": "cancelled"})
}