Fixed conditional and spacing

This commit is contained in:
TheHollidayInn
2015-05-05 20:13:53 -05:00
parent c1684414c3
commit bcb7b75380
2 changed files with 91 additions and 94 deletions
+10 -13
View File
@@ -143,20 +143,17 @@ api.get = function(req, res, next) {
//If the group is private or the group is a party, then the user must be a member of the group based on access restrictions above
if (group.privacy === 'private' || gid === 'party') {
//If the user is not in the group query, add them
if (userInGroup === undefined) { group.members.push(user); }
res.json(group);
//If the user is not in the group query, add them
if (userInGroup === undefined) { group.members.push(user); }
res.json(group);
} else if ( group.privacy === "public" ) { //The group is public, we must do an extra check to see if the user is already in the group query
//We must see how to check if a user is a member of a public group, so we requery
var q2 = Group.findOne({ _id: group._id, privacy:'public', members: {$in:[user._id]} });
q2.exec(function(err, group2){
if (err) return next(err);
if (!group2) {
if (userInGroup === undefined) { group.members.push(user); }
}
res.json(group);
});
//We must see how to check if a user is a member of a public group, so we requery
var q2 = Group.findOne({ _id: group._id, privacy:'public', members: {$in:[user._id]} });
q2.exec(function(err, group2){
if (err) return next(err);
if (!group2 && userInGroup === undefined) { group.members.push(user); }
res.json(group);
});
}
gid = null;