From 38d57cbc87881ec308a7dc37a153c7abfe0b9bfa Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sun, 4 Aug 2013 11:53:37 -0400 Subject: [PATCH] possible better handling of empty POST, yan's weird User.log({}) thing. --- src/server/apiv2.coffee | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/server/apiv2.coffee b/src/server/apiv2.coffee index a538ff8f52..a7598cea65 100644 --- a/src/server/apiv2.coffee +++ b/src/server/apiv2.coffee @@ -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