Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 38 additions & 7 deletions backend/controllers/edit_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion backend/utils/tw/edit_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Loading