mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-14 16:02:14 +00:00
Merge pull request #1563 from lefnire/paglias/big-response
Reduce response size
This commit is contained in:
commit
b0f0ec39d6
2 changed files with 10 additions and 2 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
});
|
||||
};
|
||||
Loading…
Reference in a new issue