mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 12:02:13 +00:00
Delete task for the API
This commit is contained in:
parent
1ef32c771b
commit
2b8f2f48c1
1 changed files with 9 additions and 1 deletions
|
|
@ -60,7 +60,7 @@ validateTask = (req, res, next) ->
|
|||
newTask = { type, text, notes, value, up, down, completed } = req.body
|
||||
|
||||
# If we're updating, get the task from the user
|
||||
if req.method is 'PUT'
|
||||
if req.method is 'PUT' or req.method is 'DELETE'
|
||||
task = req.userObj?.tasks[req.params.id]
|
||||
return res.json 400, err: "No task found." if !task || _.isEmpty(task)
|
||||
# Strip for now
|
||||
|
|
@ -90,6 +90,14 @@ router.put '/user/task/:id', auth, validateTask, (req, res) ->
|
|||
|
||||
res.json 200, req.task
|
||||
|
||||
router.delete '/user/task/:id', auth, validateTask, (req, res) ->
|
||||
taskIds = req.user.get("#{req.task.type}Ids")
|
||||
taskIds.splice(taskIds.indexOf(req.task.id),1)
|
||||
req.user.set "#{req.task.type}Ids", taskIds
|
||||
req.user.del "tasks.#{req.task.id}"
|
||||
|
||||
res.send 204
|
||||
|
||||
router.post '/user/task', auth, validateTask, (req, res) ->
|
||||
task = req.task
|
||||
type = task.type
|
||||
|
|
|
|||
Loading…
Reference in a new issue