apiv2 fix to pending op (@litenull)
This commit is contained in:
@@ -28,8 +28,9 @@ router.post '/', api.auth, (req, res, next) ->
|
||||
{user} = req
|
||||
actions = req.body
|
||||
|
||||
|
||||
doneCount = 1 + # cron
|
||||
actions.length # standard operations
|
||||
_.size(actions) # standard operations
|
||||
done = (err) ->
|
||||
return next(err) if err
|
||||
if --doneCount is 0
|
||||
@@ -42,6 +43,8 @@ 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
|
||||
|
||||
misc.batchTxn model, (uObj, paths) ->
|
||||
# habitrpg-shared/algos requires uObj.habits, uObj.dailys etc instead of uObj.tasks
|
||||
_.each ['habit','daily','todo','reward'], (type) -> uObj["#{type}s"] = _.where(uObj.tasks, {type}); true
|
||||
|
||||
Reference in New Issue
Block a user