mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Changed cb2 to cb and removed extra query when removing group
This commit is contained in:
@@ -87,12 +87,12 @@ GroupSchema.pre('save', function(next){
|
|||||||
GroupSchema.pre('remove', function(next) {
|
GroupSchema.pre('remove', function(next) {
|
||||||
var group = this;
|
var group = this;
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function(cb2) {
|
function(cb) {
|
||||||
User.find({
|
User.find({
|
||||||
'invitations.guilds.id': group._id
|
'invitations.guilds.id': group._id
|
||||||
}, cb2);
|
}, cb);
|
||||||
},
|
},
|
||||||
function(users, cb2) {
|
function(users, cb) {
|
||||||
if (users) {
|
if (users) {
|
||||||
users.forEach(function (user, index, array) {
|
users.forEach(function (user, index, array) {
|
||||||
var i = _.findIndex(user.invitations.guilds, {id: group._id});
|
var i = _.findIndex(user.invitations.guilds, {id: group._id});
|
||||||
@@ -100,7 +100,7 @@ GroupSchema.pre('remove', function(next) {
|
|||||||
user.save();
|
user.save();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
cb2();
|
cb();
|
||||||
}
|
}
|
||||||
], next);
|
], next);
|
||||||
});
|
});
|
||||||
@@ -426,11 +426,7 @@ GroupSchema.methods.leave = function(user, keep, mainCb){
|
|||||||
(group.type === 'guild' && group.privacy === 'private')
|
(group.type === 'guild' && group.privacy === 'private')
|
||||||
)){
|
)){
|
||||||
groupWasRemoved = true;
|
groupWasRemoved = true;
|
||||||
Group.findOne({
|
group.remove(cb)
|
||||||
_id: group._id
|
|
||||||
}, function(err, groupDoc){
|
|
||||||
groupDoc.remove(cb)
|
|
||||||
});
|
|
||||||
}else{ // otherwise just remove a member
|
}else{ // otherwise just remove a member
|
||||||
var update = {$pull: {members: user._id}};
|
var update = {$pull: {members: user._id}};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user