Merge pull request #1563 from lefnire/paglias/big-response

Reduce response size
This commit is contained in:
Tyler Renelle 2013-09-26 16:44:41 -07:00
commit b0f0ec39d6
2 changed files with 10 additions and 2 deletions

View file

@ -37,7 +37,8 @@ api.auth = function(req, res, next) {
if (_.isEmpty(user)) {
return res.json(401, NO_USER_FOUND);
}
res.locals.wasModified = +user._v !== +req.query._v;
res.locals.wasModified = req.query._v ? +user._v !== +req.query._v : true;
res.locals.user = user;
req.session.userId = user._id;
return next();

View file

@ -710,7 +710,14 @@ api.batchUpdate = function(req, res, next) {
response = user.toJSON();
response.wasModified = res.locals.wasModified;
if (response._tmp && response._tmp.drop) response.wasModified = true;
res.json(200, response);
// Send the response to the server
if(response.wasModified){
res.json(200, response);
}else{
res.json(200, {_v: response._v});
}
return console.log("Reply sent");
});
};