MCPcopy Create free account
hub / github.com/GmpABR/NexusFlow / MoveTask

Method MoveTask

backend/Controllers/TasksController.cs:67–106  ·  view source on GitHub ↗
(int id, [FromBody] MoveTaskDto dto)

Source from the content-addressed store, hash-verified

65 }
66
67 [HttpPut("{id}/move")]
68 public async Task<IActionResult> MoveTask(int id, [FromBody] MoveTaskDto dto)
69 {
70 try
71 {
72 int userId = GetUserId();
73 var task = await _taskService.MoveTaskAsync(id, dto, userId);
74 if (task == null) return NotFound();
75
76 // 1. Notify all clients on the board that the task moved columns
77 await _hubContext.Clients.Group($"board_{task.BoardId}")
78 .SendAsync("TaskMoved", task);
79
80 // 2. Execute automations and check if they modified the task natively
81 try
82 {
83 bool wasModified = await _automationService.ExecuteTaskMovedAutomationsAsync(task.BoardId, task.Id, dto.TargetColumnId, userId);
84
85 // 3. Since automations might have changed the task (assigned user, completed subtasks)
86 // if it was truly modified, fetch the latest task state and emit a TaskUpdated to sync clients.
87 if (wasModified)
88 {
89 var updatedTask = await _taskService.GetTaskByIdAsync(task.Id, userId);
90 if (updatedTask != null)
91 {
92 await _hubContext.Clients.Group($"board_{task.BoardId}")
93 .SendAsync("TaskUpdated", updatedTask);
94 return Ok(updatedTask);
95 }
96 }
97 }
98 catch (Exception ex)
99 {
100 Console.WriteLine($"[TasksController] Automations failed for task {id}: {ex.Message}");
101 }
102
103 return Ok(task);
104 }
105 catch (UnauthorizedAccessException) { return Forbid(); }
106 }
107
108 [HttpDelete("{id}")]
109 public async Task<IActionResult> DeleteTask(int id)

Callers

nothing calls this directly

Calls 3

MoveTaskAsyncMethod · 0.45
GetTaskByIdAsyncMethod · 0.45

Tested by

no test coverage detected