style changes

v1.18.x
Barış Soner Uşaklı 8 years ago
parent bcc566fb68
commit 890c2eff70

@ -1,21 +1,21 @@
'use strict';
(function (module) {
var fork = require('child_process').fork;
var path = require('path');
module.hash = function (rounds, password, callback) {
var fork = require('child_process').fork;
var path = require('path');
exports.hash = function (rounds, password, callback) {
forkChild({ type: 'hash', rounds: rounds, password: password }, callback);
};
};
module.compare = function (password, hash, callback) {
exports.compare = function (password, hash, callback) {
if (!hash || !password) {
return setImmediate(callback, null, false);
}
forkChild({ type: 'compare', password: password, hash: hash }, callback);
};
};
function forkChild(message, callback) {
function forkChild(message, callback) {
var forkProcessParams = {};
if (global.v8debug || parseInt(process.execArgv.indexOf('--debug'), 10) !== -1) {
forkProcessParams = { execArgv: ['--debug=' + (5859), '--nolazy'] };
@ -31,7 +31,4 @@
});
child.send(message);
}
return module;
}(exports));
}

@ -14,36 +14,37 @@ var file = require('./file');
var app;
var middleware;
(function (Plugins) {
require('./plugins/install')(Plugins);
require('./plugins/load')(Plugins);
require('./plugins/hooks')(Plugins);
Plugins.data = require('./plugins/data');
Plugins.getPluginPaths = Plugins.data.getPluginPaths;
Plugins.loadPluginInfo = Plugins.data.loadPluginInfo;
Plugins.pluginsData = {};
Plugins.libraries = {};
Plugins.loadedHooks = {};
Plugins.staticDirs = {};
Plugins.cssFiles = [];
Plugins.lessFiles = [];
Plugins.clientScripts = [];
Plugins.acpScripts = [];
Plugins.libraryPaths = [];
Plugins.versionWarning = [];
Plugins.soundpacks = [];
Plugins.languageData = {};
Plugins.initialized = false;
Plugins.requireLibrary = function (pluginID, libraryPath) {
var Plugins = module.exports;
require('./plugins/install')(Plugins);
require('./plugins/load')(Plugins);
require('./plugins/hooks')(Plugins);
Plugins.data = require('./plugins/data');
Plugins.getPluginPaths = Plugins.data.getPluginPaths;
Plugins.loadPluginInfo = Plugins.data.loadPluginInfo;
Plugins.pluginsData = {};
Plugins.libraries = {};
Plugins.loadedHooks = {};
Plugins.staticDirs = {};
Plugins.cssFiles = [];
Plugins.lessFiles = [];
Plugins.clientScripts = [];
Plugins.acpScripts = [];
Plugins.libraryPaths = [];
Plugins.versionWarning = [];
Plugins.soundpacks = [];
Plugins.languageData = {};
Plugins.initialized = false;
Plugins.requireLibrary = function (pluginID, libraryPath) {
Plugins.libraries[pluginID] = require(libraryPath);
Plugins.libraryPaths.push(libraryPath);
};
};
Plugins.init = function (nbbApp, nbbMiddleware, callback) {
Plugins.init = function (nbbApp, nbbMiddleware, callback) {
callback = callback || function () {};
if (Plugins.initialized) {
return callback();
@ -72,9 +73,9 @@ var middleware;
Plugins.initialized = true;
callback();
});
};
};
Plugins.reload = function (callback) {
Plugins.reload = function (callback) {
// Resetting all local plugin data
Plugins.libraries = {};
Plugins.loadedHooks = {};
@ -112,9 +113,9 @@ var middleware;
next();
},
], callback);
};
};
Plugins.reloadRoutes = function (callback) {
Plugins.reloadRoutes = function (callback) {
var router = express.Router();
router.hotswapId = 'plugins';
@ -133,9 +134,9 @@ var middleware;
winston.verbose('[plugins] All plugins reloaded and rerouted');
callback();
});
};
};
Plugins.getTemplates = function (callback) {
Plugins.getTemplates = function (callback) {
var templates = {};
var tplName;
@ -178,9 +179,9 @@ var middleware;
callback(err, templates);
});
});
};
};
Plugins.get = function (id, callback) {
Plugins.get = function (id, callback) {
var url = (nconf.get('registry') || 'https://packages.nodebb.org') + '/api/v1/plugins/' + id;
require('request')(url, {
@ -197,9 +198,9 @@ var middleware;
return callback(err, !err ? normalised[0] : undefined);
});
});
};
};
Plugins.list = function (matching, callback) {
Plugins.list = function (matching, callback) {
if (arguments.length === 1 && typeof matching === 'function') {
callback = matching;
matching = true;
@ -217,9 +218,9 @@ var middleware;
Plugins.normalise(body, callback);
});
};
};
Plugins.normalise = function (apiReturn, callback) {
Plugins.normalise = function (apiReturn, callback) {
var pluginMap = {};
var dependencies = require(path.join(nconf.get('base_dir'), 'package.json')).dependencies;
apiReturn = apiReturn || [];
@ -294,9 +295,9 @@ var middleware;
callback(null, pluginArray);
});
});
};
};
Plugins.showInstalled = function (callback) {
Plugins.showInstalled = function (callback) {
var npmPluginPath = path.join(__dirname, '../node_modules');
async.waterfall([
@ -360,5 +361,4 @@ var middleware;
});
},
], callback);
};
}(exports));
};

@ -12,29 +12,30 @@ var categories = require('./categories');
var privileges = require('./privileges');
var social = require('./social');
(function (Topics) {
require('./topics/data')(Topics);
require('./topics/create')(Topics);
require('./topics/delete')(Topics);
require('./topics/unread')(Topics);
require('./topics/recent')(Topics);
require('./topics/popular')(Topics);
require('./topics/user')(Topics);
require('./topics/fork')(Topics);
require('./topics/posts')(Topics);
require('./topics/follow')(Topics);
require('./topics/tags')(Topics);
require('./topics/teaser')(Topics);
require('./topics/suggested')(Topics);
require('./topics/tools')(Topics);
require('./topics/thumb')(Topics);
require('./topics/bookmarks')(Topics);
Topics.exists = function (tid, callback) {
var Topics = module.exports;
require('./topics/data')(Topics);
require('./topics/create')(Topics);
require('./topics/delete')(Topics);
require('./topics/unread')(Topics);
require('./topics/recent')(Topics);
require('./topics/popular')(Topics);
require('./topics/user')(Topics);
require('./topics/fork')(Topics);
require('./topics/posts')(Topics);
require('./topics/follow')(Topics);
require('./topics/tags')(Topics);
require('./topics/teaser')(Topics);
require('./topics/suggested')(Topics);
require('./topics/tools')(Topics);
require('./topics/thumb')(Topics);
require('./topics/bookmarks')(Topics);
Topics.exists = function (tid, callback) {
db.isSortedSetMember('topics:tid', tid, callback);
};
};
Topics.getPageCount = function (tid, uid, callback) {
Topics.getPageCount = function (tid, uid, callback) {
var postCount;
async.waterfall([
function (next) {
@ -51,14 +52,14 @@ var social = require('./social');
next(null, Math.ceil((parseInt(postCount, 10) - 1) / settings.postsPerPage));
},
], callback);
};
};
Topics.getTidPage = function (tid, uid, callback) {
Topics.getTidPage = function (tid, uid, callback) {
console.warn('[Topics.getTidPage] deprecated!');
callback(null, 1);
};
};
Topics.getTopicsFromSet = function (set, uid, start, stop, callback) {
Topics.getTopicsFromSet = function (set, uid, start, stop, callback) {
async.waterfall([
function (next) {
db.getSortedSetRevRange(set, start, stop, next);
@ -70,9 +71,9 @@ var social = require('./social');
next(null, { topics: topics, nextStart: stop + 1 });
},
], callback);
};
};
Topics.getTopics = function (tids, uid, callback) {
Topics.getTopics = function (tids, uid, callback) {
async.waterfall([
function (next) {
privileges.topics.filterTids('read', tids, uid, next);
@ -81,9 +82,9 @@ var social = require('./social');
Topics.getTopicsByTids(tids, uid, next);
},
], callback);
};
};
Topics.getTopicsByTids = function (tids, uid, callback) {
Topics.getTopicsByTids = function (tids, uid, callback) {
if (!Array.isArray(tids) || !tids.length) {
return callback(null, []);
}
@ -167,9 +168,9 @@ var social = require('./social');
next(null, data.topics);
},
], callback);
};
};
Topics.getTopicWithPosts = function (topicData, set, uid, start, stop, reverse, callback) {
Topics.getTopicWithPosts = function (topicData, set, uid, start, stop, reverse, callback) {
async.waterfall([
function (next) {
async.parallel({
@ -220,9 +221,9 @@ var social = require('./social');
next(null, data.topic);
},
], callback);
};
};
function getMainPostAndReplies(topic, set, uid, start, stop, reverse, callback) {
function getMainPostAndReplies(topic, set, uid, start, stop, reverse, callback) {
async.waterfall([
function (next) {
if (stop > 0) {
@ -259,68 +260,72 @@ var social = require('./social');
Topics.addPostData(posts, uid, next);
},
], callback);
}
}
function getDeleter(topicData, callback) {
function getDeleter(topicData, callback) {
if (!topicData.deleterUid) {
return setImmediate(callback, null, null);
}
user.getUserFields(topicData.deleterUid, ['username', 'userslug', 'picture'], callback);
}
}
Topics.getMainPost = function (tid, uid, callback) {
Topics.getMainPost = function (tid, uid, callback) {
Topics.getMainPosts([tid], uid, function (err, mainPosts) {
callback(err, Array.isArray(mainPosts) && mainPosts.length ? mainPosts[0] : null);
});
};
};
Topics.getMainPids = function (tids, callback) {
Topics.getMainPids = function (tids, callback) {
if (!Array.isArray(tids) || !tids.length) {
return callback(null, []);
}
Topics.getTopicsFields(tids, ['mainPid'], function (err, topicData) {
if (err) {
return callback(err);
}
async.waterfall([
function (next) {
Topics.getTopicsFields(tids, ['mainPid'], next);
},
function (topicData, next) {
var mainPids = topicData.map(function (topic) {
return topic && topic.mainPid;
});
callback(null, mainPids);
});
};
next(null, mainPids);
},
], callback);
};
Topics.getMainPosts = function (tids, uid, callback) {
Topics.getMainPids(tids, function (err, mainPids) {
if (err) {
return callback(err);
}
getMainPosts(mainPids, uid, callback);
});
};
Topics.getMainPosts = function (tids, uid, callback) {
async.waterfall([
function (next) {
Topics.getMainPids(tids, next);
},
function (mainPids, next) {
getMainPosts(mainPids, uid, next);
},
], callback);
};
function getMainPosts(mainPids, uid, callback) {
posts.getPostsByPids(mainPids, uid, function (err, postData) {
if (err) {
return callback(err);
}
function getMainPosts(mainPids, uid, callback) {
async.waterfall([
function (next) {
posts.getPostsByPids(mainPids, uid, next);
},
function (postData, next) {
postData.forEach(function (post) {
if (post) {
post.index = 0;
}
});
Topics.addPostData(postData, uid, callback);
});
}
Topics.addPostData(postData, uid, next);
},
], callback);
}
Topics.isLocked = function (tid, callback) {
Topics.isLocked = function (tid, callback) {
Topics.getTopicField(tid, 'locked', function (err, locked) {
callback(err, parseInt(locked, 10) === 1);
});
};
};
Topics.search = function (tid, term, callback) {
Topics.search = function (tid, term, callback) {
if (plugins.hasListeners('filter:topic.search')) {
plugins.fireHook('filter:topic.search', {
tid: tid,
@ -329,5 +334,4 @@ var social = require('./social');
} else {
callback(new Error('[[error:no-plugins-available]]'), []);
}
};
}(exports));
};

@ -12,20 +12,21 @@ var db = require('../database');
var meta = require('../meta');
var emailer = require('../emailer');
(function (UserEmail) {
UserEmail.exists = function (email, callback) {
var UserEmail = module.exports;
UserEmail.exists = function (email, callback) {
user.getUidByEmail(email.toLowerCase(), function (err, exists) {
callback(err, !!exists);
});
};
};
UserEmail.available = function (email, callback) {
UserEmail.available = function (email, callback) {
db.isSortedSetMember('email:uid', email.toLowerCase(), function (err, exists) {
callback(err, !exists);
});
};
};
UserEmail.sendValidationEmail = function (uid, email, callback) {
UserEmail.sendValidationEmail = function (uid, email, callback) {
callback = callback || function () {};
var confirm_code = utils.generateUUID();
var confirm_link = nconf.get('url') + '/confirm/' + confirm_code;
@ -87,9 +88,9 @@ var emailer = require('../emailer');
next(null, confirm_code);
},
], callback);
};
};
UserEmail.confirm = function (code, callback) {
UserEmail.confirm = function (code, callback) {
async.waterfall([
function (next) {
db.getObject('confirm:' + code, next);
@ -113,5 +114,4 @@ var emailer = require('../emailer');
], function (err) {
callback(err);
});
};
}(exports));
};

@ -12,10 +12,11 @@ var db = require('../database');
var meta = require('../meta');
var emailer = require('../emailer');
(function (UserReset) {
var twoHours = 7200000;
var UserReset = module.exports;
UserReset.validate = function (code, callback) {
var twoHours = 7200000;
UserReset.validate = function (code, callback) {
async.waterfall([
function (next) {
db.getObjectField('reset:uid', code, next);
@ -30,9 +31,9 @@ var emailer = require('../emailer');
next(null, parseInt(issueDate, 10) > Date.now() - twoHours);
},
], callback);
};
};
UserReset.generate = function (uid, callback) {
UserReset.generate = function (uid, callback) {
var code = utils.generateUUID();
async.parallel([
async.apply(db.setObjectField, 'reset:uid', code, uid),
@ -40,9 +41,9 @@ var emailer = require('../emailer');
], function (err) {
callback(err, code);
});
};
};
function canGenerate(uid, callback) {
function canGenerate(uid, callback) {
async.waterfall([
function (next) {
db.sortedSetScore('reset:issueDate:uid', uid, next);
@ -54,9 +55,9 @@ var emailer = require('../emailer');
next();
},
], callback);
}
}
UserReset.send = function (email, callback) {
UserReset.send = function (email, callback) {
var uid;
async.waterfall([
function (next) {
@ -92,9 +93,9 @@ var emailer = require('../emailer');
}, next);
},
], callback);
};
};
UserReset.commit = function (code, password, callback) {
UserReset.commit = function (code, password, callback) {
var uid;
async.waterfall([
function (next) {
@ -128,18 +129,18 @@ var emailer = require('../emailer');
], next);
},
], callback);
};
};
UserReset.updateExpiry = function (uid, callback) {
UserReset.updateExpiry = function (uid, callback) {
var oneDay = 1000 * 60 * 60 * 24;
var expireDays = parseInt(meta.config.passwordExpiryDays || 0, 10);
var expiry = Date.now() + (oneDay * expireDays);
callback = callback || function () {};
user.setUserField(uid, 'passwordExpiry', expireDays > 0 ? expiry : 0, callback);
};
};
UserReset.clean = function (callback) {
UserReset.clean = function (callback) {
async.waterfall([
function (next) {
async.parallel({
@ -164,5 +165,4 @@ var emailer = require('../emailer');
], next);
},
], callback);
};
}(exports));
};

Loading…
Cancel
Save