possible better handling of empty POST, yan's weird User.log({}) thing.

This commit is contained in:
Tyler Renelle 2013-08-04 11:53:37 -04:00
parent 8760d07215
commit 38d57cbc87

View file

@ -28,7 +28,6 @@ router.post '/', api.auth, (req, res, next) ->
{user} = req
actions = req.body
doneCount = 1 + # cron
_.size(actions) # standard operations
done = (err) ->
@ -43,7 +42,11 @@ router.post '/', api.auth, (req, res, next) ->
res.json 200, uObj
console.log "Reply sent"
if _.isObject(actions) and _.isEmpty(actions) then done() # first request, empty object
notEmpty = _.find actions, ((action) -> !_.isEmpty(action))
unless notEmpty
# yan's strange User.log({}) thing
doneCount = 1
return done()
misc.batchTxn model, (uObj, paths) ->
# habitrpg-shared/algos requires uObj.habits, uObj.dailys etc instead of uObj.tasks