dont call groups.get just to read 2 values

v1.18.x
Barış Soner Uşaklı 10 years ago
parent 3f1726636f
commit 50d9a3f0a7

@ -647,13 +647,12 @@ var async = require('async'),
uid: uid uid: uid
}); });
// If this is a hidden group, and it is now empty, delete it Groups.getGroupFields(groupName, ['hidden', 'memberCount'], function(err, groupData) {
Groups.get(groupName, {}, function(err, group) { if (err || !groupData) {
if (err || !group) {
return callback(err); return callback(err);
} }
if (group.hidden && group.memberCount === 0) { if (parseInt(groupData.hidden, 10) === 1 && parseInt(groupData.memberCount, 10) === 0) {
Groups.destroy(groupName, callback); Groups.destroy(groupName, callback);
} else { } else {
callback(); callback();

Loading…
Cancel
Save