Merge branch 'develop' into hairlessbear-quest_invite_modal_on_user_sync

This commit is contained in:
Blade Barringer
2015-06-20 17:36:32 -05:00
259 changed files with 9481 additions and 8493 deletions
+1 -6
View File
@@ -211,7 +211,6 @@ api.create = function(req, res, next) {
if (err == 'Already in a party, try refreshing.') return res.json(400,{err:err});
if (err) return next(err);
return res.json(populated);
group = user = null;
})
}
}
@@ -286,7 +285,6 @@ api.postChat = function(req, res, next) {
group.save(function(err, saved){
if (err) return next(err);
return chatUpdated ? res.json({chat: group.chat}) : res.json({message: saved.chat[0]});
group = chatUpdated = null;
});
}
}
@@ -306,8 +304,7 @@ api.deleteChatMessage = function(req, res, next){
Group.update({_id:group._id}, {$pull:{chat:{id: req.params.messageId}}}, function(err){
if(err) return next(err);
chatUpdated ? res.json({chat: group.chat}) : res.send(204);
group = chatUpdated = null;
return chatUpdated ? res.json({chat: group.chat}) : res.send(204);
});
}
@@ -553,7 +550,6 @@ api.leave = function(req, res, next) {
],function(err){
if (err) return next(err);
return res.send(204);
user = group = keep = null;
})
}
@@ -790,7 +786,6 @@ api.removeMember = function(req, res, next){
});
}else{
return res.json(400, {err: "User not found among group's members!"});
group = uuid = null;
}
}
+43 -35
View File
@@ -6,7 +6,7 @@ var nconf = require('nconf');
var inAppPurchase = require('in-app-purchase');
inAppPurchase.config({
// this is the path to the directory containing iap-sanbox/iap-live files
googlePublicKeyPath: nconf.get("IAP_GOOGLE_KEYDIR")
googlePublicKeyPath: nconf.get("IAP_GOOGLE_KEYDIR")
});
// Validation ERROR Codes
@@ -24,15 +24,11 @@ exports.androidVerify = function(req, res, next) {
ok: false,
data: 'IAP Error'
};
console.error('IAP Setup ERROR');
console.error(error);
res.json(resObj);
return;
return res.json(resObj);
}
/*
google receipt must be provided as an object
{
@@ -44,7 +40,7 @@ exports.androidVerify = function(req, res, next) {
data: iapBody.transaction.receipt,
signature: iapBody.transaction.signature
};
// iap is ready
iap.validate(iap.GOOGLE, testObj, function (err, googleRes) {
if (err) {
@@ -56,9 +52,7 @@ exports.androidVerify = function(req, res, next) {
}
};
res.json(resObj);
console.error(err);
return;
return res.json(resObj);
}
if (iap.isValidated(googleRes)) {
@@ -69,16 +63,13 @@ exports.androidVerify = function(req, res, next) {
payments.buyGems({user:user, paymentMethod:'IAP GooglePlay'});
// yay good!
res.json(resObj);
return res.json(resObj);
}
});
});
};
exports.iosVerify = function(req, res, next) {
console.info(req.body);
var iapBody = req.body;
var user = res.locals.user;
@@ -89,15 +80,11 @@ exports.iosVerify = function(req, res, next) {
data: 'IAP Error'
};
console.error('IAP Setup ERROR');
console.error(error);
return res.json(resObj);
res.json(resObj);
return;
}
// iap is ready
//iap is ready
iap.validate(iap.APPLE, iapBody.transaction.receipt, function (err, appleRes) {
if (err) {
var resObj = {
@@ -108,22 +95,43 @@ exports.iosVerify = function(req, res, next) {
}
};
res.json(resObj);
console.error(err);
return;
return res.json(resObj);
}
if (iap.isValidated(appleRes)) {
var purchaseDataList = iap.getPurchaseData(appleRes);
if (purchaseDataList.length > 0) {
if (purchaseDataList[0].productId === "com.habitrpg.ios.Habitica.20gems") {
//Correct receipt
payments.buyGems({user:user, paymentMethod:'IAP AppleStore'});
var resObj = {
ok: true,
data: appleRes
};
// yay good!
return res.json(resObj);
}
}
//wrong receipt content
var resObj = {
ok: true,
data: appleRes
ok: false,
data: {
code: INVALID_PAYLOAD,
message: "Incorrect receipt content"
}
};
payments.buyGems({user:user, paymentMethod:'IAP AppleStore'});
// yay good!
res.json(resObj);
return res.json(resObj);
}
//invalid receipt
var resObj = {
ok: false,
data: {
code: INVALID_PAYLOAD,
message: "Invalid receipt"
}
};
return res.json(resObj);
});
});
};
};
+3 -1
View File
@@ -99,9 +99,11 @@ api.score = function(req, res, next) {
text: req.body && req.body.text,
notes: (req.body && req.body.notes) || "This task was created by a third-party service. Feel free to edit, it won't harm the connection to that service. Additionally, multiple services may piggy-back off this task."
};
task = user.ops.addTask({body:task});
if (task.type === 'daily' || task.type === 'todo')
task.completed = direction === 'up';
task = user.ops.addTask({body:task});
}
var delta = user.ops.score({params:{id:task.id, direction:direction}, language: req.language});