mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-10 16:05:49 +01:00
closes #3223
This commit is contained in:
@@ -379,8 +379,6 @@ var async = require('async'),
|
|||||||
db.getSortedSetRevRange('groups:visible:createtime', 0, -1, next);
|
db.getSortedSetRevRange('groups:visible:createtime', 0, -1, next);
|
||||||
},
|
},
|
||||||
function(groupNames, next) {
|
function(groupNames, next) {
|
||||||
groupNames.push('administrators');
|
|
||||||
|
|
||||||
var groupSets = groupNames.map(function(name) {
|
var groupSets = groupNames.map(function(name) {
|
||||||
return 'group:' + name + ':members';
|
return 'group:' + name + ':members';
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -74,7 +74,8 @@ module.exports = function(Groups) {
|
|||||||
async.parallel([
|
async.parallel([
|
||||||
async.apply(db.sortedSetRemove, 'groups:visible:createtime', groupName),
|
async.apply(db.sortedSetRemove, 'groups:visible:createtime', groupName),
|
||||||
async.apply(db.sortedSetRemove, 'groups:visible:memberCount', groupName),
|
async.apply(db.sortedSetRemove, 'groups:visible:memberCount', groupName),
|
||||||
async.apply(db.sortedSetRemove, 'groups:visible:name', groupName.toLowerCase() + ':' + groupName)
|
async.apply(db.sortedSetRemove, 'groups:visible:name', groupName.toLowerCase() + ':' + groupName),
|
||||||
|
async.apply(db.deleteObjectField, 'groupslug:groupname', utils.slugify(groupName))
|
||||||
], callback);
|
], callback);
|
||||||
} else {
|
} else {
|
||||||
db.getObjectFields('group:' + groupName, ['createtime', 'memberCount'], function(err, groupData) {
|
db.getObjectFields('group:' + groupName, ['createtime', 'memberCount'], function(err, groupData) {
|
||||||
@@ -84,7 +85,8 @@ module.exports = function(Groups) {
|
|||||||
async.parallel([
|
async.parallel([
|
||||||
async.apply(db.sortedSetAdd, 'groups:visible:createtime', groupData.createtime, groupName),
|
async.apply(db.sortedSetAdd, 'groups:visible:createtime', groupData.createtime, groupName),
|
||||||
async.apply(db.sortedSetAdd, 'groups:visible:memberCount', groupData.memberCount, groupName),
|
async.apply(db.sortedSetAdd, 'groups:visible:memberCount', groupData.memberCount, groupName),
|
||||||
async.apply(db.sortedSetAdd, 'groups:visible:name', 0, groupName.toLowerCase() + ':' + groupName)
|
async.apply(db.sortedSetAdd, 'groups:visible:name', 0, groupName.toLowerCase() + ':' + groupName),
|
||||||
|
async.apply(db.setObjectField, 'groupslug:groupname', utils.slugify(groupName), groupName)
|
||||||
], callback);
|
], callback);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -92,7 +94,22 @@ module.exports = function(Groups) {
|
|||||||
|
|
||||||
Groups.hide = function(groupName, callback) {
|
Groups.hide = function(groupName, callback) {
|
||||||
callback = callback || function() {};
|
callback = callback || function() {};
|
||||||
db.setObjectField('group:' + groupName, 'hidden', 1, callback);
|
async.parallel([
|
||||||
|
async.apply(db.setObjectField, 'group:' + groupName, 'hidden', 1),
|
||||||
|
async.apply(updateVisibility, groupName, true)
|
||||||
|
], function(err, results) {
|
||||||
|
callback(err);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Groups.show = function(groupName, callback) {
|
||||||
|
callback = callback || function() {};
|
||||||
|
async.parallel([
|
||||||
|
async.apply(db.setObjectField, 'group:' + groupName, 'hidden', 0),
|
||||||
|
async.apply(updateVisibility, groupName, false)
|
||||||
|
], function(err, results) {
|
||||||
|
callback(err);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Groups.updateCoverPosition = function(groupName, position, callback) {
|
Groups.updateCoverPosition = function(groupName, position, callback) {
|
||||||
|
|||||||
@@ -348,15 +348,21 @@ function createAdmin(callback) {
|
|||||||
return retryPassword(results);
|
return retryPassword(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
User.create({username: results.username, password: results.password, email: results.email}, function (err, uid) {
|
async.waterfall([
|
||||||
if (err) {
|
function(next) {
|
||||||
winston.warn(err.message + ' Please try again.');
|
User.create({username: results.username, password: results.password, email: results.email}, next);
|
||||||
return callback(new Error('invalid-values'));
|
},
|
||||||
|
function(uid, next) {
|
||||||
|
Groups.join('administrators', uid, next);
|
||||||
|
},
|
||||||
|
function(next) {
|
||||||
|
Groups.show('administrators', next);
|
||||||
}
|
}
|
||||||
|
], function(err) {
|
||||||
Groups.join('administrators', uid, function(err) {
|
if (err) {
|
||||||
callback(err, password ? results : undefined);
|
return callback(err);
|
||||||
});
|
}
|
||||||
|
callback(null, password ? results : undefined);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
retryPassword = function (originalResults) {
|
retryPassword = function (originalResults) {
|
||||||
|
|||||||
Reference in New Issue
Block a user