diff --git a/backend/controllers/edit_task.go b/backend/controllers/edit_task.go index 1e65a851..1769e156 100644 --- a/backend/controllers/edit_task.go +++ b/backend/controllers/edit_task.go @@ -31,8 +31,6 @@ func EditTaskHandler(w http.ResponseWriter, r *http.Request) { } defer r.Body.Close() - // fmt.Printf("Raw request body: %s\n", string(body)) - var requestBody models.EditTaskRequestBody err = json.Unmarshal(body, &requestBody) @@ -62,7 +60,6 @@ func EditTaskHandler(w http.ResponseWriter, r *http.Request) { return } - // Validate dependencies origin := os.Getenv("CONTAINER_ORIGIN") existingTasks, err := tw.FetchTasksFromTaskwarrior(email, encryptionSecret, origin, uuid) if err != nil { @@ -120,16 +117,50 @@ func EditTaskHandler(w http.ResponseWriter, r *http.Request) { job := Job{ Name: "Edit Task", Execute: func() error { - logStore.AddLog("INFO", fmt.Sprintf("Editing task ID: %s", taskUUID), uuid, "Edit Task") - err := tw.EditTaskInTaskwarrior(uuid, description, email, encryptionSecret, taskUUID, tags, project, start, entry, wait, end, depends, due, recur, annotations) + logStore.AddLog( + "INFO", + fmt.Sprintf("Editing task ID: %s", taskUUID), + uuid, + "Edit Task", + ) + + err := tw.EditTaskInTaskwarrior( + uuid, + description, + email, + encryptionSecret, + taskUUID, + tags, + project, + start, + entry, + wait, + end, + depends, + due, + recur, + annotations, + ) if err != nil { - logStore.AddLog("ERROR", fmt.Sprintf("Failed to edit task ID %s: %v", taskUUID, err), uuid, "Edit Task") + logStore.AddLog( + "ERROR", + fmt.Sprintf("Failed to edit task ID %s: %v", taskUUID, err), + uuid, + "Edit Task", + ) return err } - logStore.AddLog("INFO", fmt.Sprintf("Successfully edited task ID: %s", taskUUID), uuid, "Edit Task") + + logStore.AddLog( + "INFO", + fmt.Sprintf("Successfully edited task ID: %s", taskUUID), + uuid, + "Edit Task", + ) return nil }, } + GlobalJobQueue.AddJob(job) w.WriteHeader(http.StatusAccepted) diff --git a/backend/utils/tw/edit_task.go b/backend/utils/tw/edit_task.go index 3207a5b6..4d2190ad 100644 --- a/backend/utils/tw/edit_task.go +++ b/backend/utils/tw/edit_task.go @@ -13,7 +13,8 @@ func EditTaskInTaskwarrior(uuid, description, email, encryptionSecret, taskID st if err := utils.ExecCommand("rm", "-rf", "/root/.task"); err != nil { return fmt.Errorf("error deleting Taskwarrior data: %v", err) } - tempDir, err := os.MkdirTemp("", utils.SafeTempDirPrefix("taskwarrior-", email)) + + tempDir, err := os.MkdirTemp("", "taskwarrior-"+email) if err != nil { return fmt.Errorf("failed to create temporary directory: %v", err) }