Merge branch 'develop' of github.com:lefnire/habitrpg into develop

This commit is contained in:
Tyler Renelle
2013-03-09 11:03:57 -05:00
2 changed files with 36 additions and 2 deletions
+10 -2
View File
@@ -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,15 @@ 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"
req.user.del "tasks.#{req.task.id}"
# Remove one id from array of typeIds
req.user.remove "#{req.task.type}Ids", taskIds.indexOf(req.task.id), 1
res.send 204
router.post '/user/task', auth, validateTask, (req, res) ->
task = req.task
type = task.type
@@ -156,4 +165,3 @@ router.post '/user/tasks/:taskId/:direction', auth, scoreTask
module.exports = router
module.exports.auth = auth
module.exports.scoreTask = scoreTask # export so deprecated can call it