mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 03:52:14 +00:00
Separated the deletion of the challenge to its own function in the async.waterfall
This commit is contained in:
parent
46cb0240c3
commit
c18fbb79ed
1 changed files with 6 additions and 2 deletions
|
|
@ -309,12 +309,16 @@ api['delete'] = function(req, res, next){
|
|||
chal = _chal;
|
||||
if (!chal) return cb('Challenge ' + cid + ' not found');
|
||||
if (chal.leader != user._id) return cb("You don't have permissions to edit this challenge");
|
||||
User.findById(user._id, cb) //Refunds to challenge leader
|
||||
//Refunds to challenge leader
|
||||
User.findById(user._id, cb)
|
||||
},
|
||||
function(leader, cb){
|
||||
leader.balance += chal.prize/4;
|
||||
leader.save(cb);
|
||||
closeChal(req.params.cid, {broken: 'CHALLENGE_DELETED'}, cb); //Not descriptive enough
|
||||
},
|
||||
function(save, num, cb){
|
||||
//Add prizeRefundedTo: save.profile.name?
|
||||
closeChal(req.params.cid, {broken: 'CHALLENGE_DELETED'}, cb);
|
||||
}
|
||||
], function(err){
|
||||
if (err) return next(err);
|
||||
|
|
|
|||
Loading…
Reference in a new issue