mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-22 00:10:25 +01:00
some more refactors
This commit is contained in:
@@ -243,26 +243,23 @@ Groups.getGroupNameByGroupSlug = function (slug, callback) {
|
||||
};
|
||||
|
||||
Groups.isPrivate = function (groupName, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
db.getObjectField('group:' + groupName, 'private', next);
|
||||
},
|
||||
function (isPrivate, next) {
|
||||
next(null, parseInt(isPrivate, 10) !== 0);
|
||||
},
|
||||
], callback);
|
||||
isFieldOn(groupName, 'private', callback);
|
||||
};
|
||||
|
||||
Groups.isHidden = function (groupName, callback) {
|
||||
isFieldOn(groupName, 'hidden', callback);
|
||||
};
|
||||
|
||||
function isFieldOn(groupName, field, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
db.getObjectField('group:' + groupName, 'hidden', next);
|
||||
db.getObjectField('group:' + groupName, field, next);
|
||||
},
|
||||
function (isHidden, next) {
|
||||
next(null, parseInt(isHidden, 10) === 1);
|
||||
function (value, next) {
|
||||
next(null, parseInt(value, 10) === 1);
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
}
|
||||
|
||||
Groups.exists = function (name, callback) {
|
||||
if (Array.isArray(name)) {
|
||||
|
||||
@@ -15,6 +15,14 @@ module.exports = function (User) {
|
||||
var fields = ['username', 'email', 'fullname', 'website', 'location',
|
||||
'groupTitle', 'birthday', 'signature', 'aboutme'];
|
||||
|
||||
if (data.aboutme !== undefined && data.aboutme.length > meta.config.maximumAboutMeLength) {
|
||||
return callback(new Error('[[error:about-me-too-long, ' + meta.config.maximumAboutMeLength + ']]'));
|
||||
}
|
||||
|
||||
if (data.signature !== undefined && data.signature.length > meta.config.maximumSignatureLength) {
|
||||
return callback(new Error('[[error:signature-too-long, ' + meta.config.maximumSignatureLength + ']]'));
|
||||
}
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
plugins.fireHook('filter:user.updateProfile', { uid: uid, data: data, fields: fields }, next);
|
||||
@@ -24,8 +32,6 @@ module.exports = function (User) {
|
||||
data = data.data;
|
||||
|
||||
async.series([
|
||||
async.apply(isAboutMeValid, data),
|
||||
async.apply(isSignatureValid, data),
|
||||
async.apply(isEmailAvailable, data, uid),
|
||||
async.apply(isUsernameAvailable, data, uid),
|
||||
async.apply(isGroupTitleValid, data),
|
||||
@@ -61,22 +67,6 @@ module.exports = function (User) {
|
||||
], callback);
|
||||
};
|
||||
|
||||
function isAboutMeValid(data, callback) {
|
||||
if (data.aboutme !== undefined && data.aboutme.length > meta.config.maximumAboutMeLength) {
|
||||
callback(new Error('[[error:about-me-too-long, ' + meta.config.maximumAboutMeLength + ']]'));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
function isSignatureValid(data, callback) {
|
||||
if (data.signature !== undefined && data.signature.length > meta.config.maximumSignatureLength) {
|
||||
callback(new Error('[[error:signature-too-long, ' + meta.config.maximumSignatureLength + ']]'));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
function isEmailAvailable(data, uid, callback) {
|
||||
if (!data.email) {
|
||||
return callback();
|
||||
|
||||
@@ -61,11 +61,9 @@ module.exports.listen = function (callback) {
|
||||
|
||||
logger.init(app);
|
||||
|
||||
initializeNodeBB(function (err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
async.waterfall([
|
||||
initializeNodeBB,
|
||||
function (next) {
|
||||
winston.info('NodeBB Ready');
|
||||
|
||||
require('./socket.io').server.emit('event:nodebb.ready', {
|
||||
@@ -74,8 +72,9 @@ module.exports.listen = function (callback) {
|
||||
|
||||
plugins.fireHook('action:nodebb.ready');
|
||||
|
||||
listen(callback);
|
||||
});
|
||||
listen(next);
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
function initializeNodeBB(callback) {
|
||||
@@ -107,7 +106,9 @@ function initializeNodeBB(callback) {
|
||||
meta.blacklist.load,
|
||||
], next);
|
||||
},
|
||||
], callback);
|
||||
], function (err) {
|
||||
callback(err);
|
||||
});
|
||||
}
|
||||
|
||||
function setupExpressApp(app) {
|
||||
|
||||
Reference in New Issue
Block a user