mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
Fix space-before-function-paren linter rule
This commit is contained in:
@@ -9,7 +9,7 @@ var Groups = require('./groups');
|
||||
var plugins = require('./plugins');
|
||||
var privileges = require('./privileges');
|
||||
|
||||
(function(Categories) {
|
||||
(function (Categories) {
|
||||
|
||||
require('./categories/data')(Categories);
|
||||
require('./categories/create')(Categories);
|
||||
@@ -20,11 +20,11 @@ var privileges = require('./privileges');
|
||||
require('./categories/recentreplies')(Categories);
|
||||
require('./categories/update')(Categories);
|
||||
|
||||
Categories.exists = function(cid, callback) {
|
||||
Categories.exists = function (cid, callback) {
|
||||
db.isSortedSetMember('categories:cid', cid, callback);
|
||||
};
|
||||
|
||||
Categories.getCategoryById = function(data, callback) {
|
||||
Categories.getCategoryById = function (data, callback) {
|
||||
var category;
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
@@ -37,17 +37,17 @@ var privileges = require('./privileges');
|
||||
category = categories[0];
|
||||
|
||||
async.parallel({
|
||||
topics: function(next) {
|
||||
topics: function (next) {
|
||||
Categories.getCategoryTopics(data, next);
|
||||
},
|
||||
topicCount: function(next) {
|
||||
topicCount: function (next) {
|
||||
if (Array.isArray(data.set)) {
|
||||
db.sortedSetIntersectCard(data.set, next);
|
||||
} else {
|
||||
next(null, category.topic_count);
|
||||
}
|
||||
},
|
||||
isIgnored: function(next) {
|
||||
isIgnored: function (next) {
|
||||
Categories.isIgnored([data.cid], data.uid, next);
|
||||
}
|
||||
}, next);
|
||||
@@ -66,24 +66,24 @@ var privileges = require('./privileges');
|
||||
], callback);
|
||||
};
|
||||
|
||||
Categories.isIgnored = function(cids, uid, callback) {
|
||||
user.getIgnoredCategories(uid, function(err, ignoredCids) {
|
||||
Categories.isIgnored = function (cids, uid, callback) {
|
||||
user.getIgnoredCategories(uid, function (err, ignoredCids) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
cids = cids.map(function(cid) {
|
||||
cids = cids.map(function (cid) {
|
||||
return ignoredCids.indexOf(cid.toString()) !== -1;
|
||||
});
|
||||
callback(null, cids);
|
||||
});
|
||||
};
|
||||
|
||||
Categories.getPageCount = function(cid, uid, callback) {
|
||||
Categories.getPageCount = function (cid, uid, callback) {
|
||||
async.parallel({
|
||||
topicCount: async.apply(Categories.getCategoryField, cid, 'topic_count'),
|
||||
settings: async.apply(user.getSettings, uid)
|
||||
}, function(err, results) {
|
||||
}, function (err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -96,8 +96,8 @@ var privileges = require('./privileges');
|
||||
});
|
||||
};
|
||||
|
||||
Categories.getAllCategories = function(uid, callback) {
|
||||
db.getSortedSetRange('categories:cid', 0, -1, function(err, cids) {
|
||||
Categories.getAllCategories = function (uid, callback) {
|
||||
db.getSortedSetRange('categories:cid', 0, -1, function (err, cids) {
|
||||
if (err || !Array.isArray(cids) || !cids.length) {
|
||||
return callback(err, []);
|
||||
}
|
||||
@@ -106,22 +106,22 @@ var privileges = require('./privileges');
|
||||
});
|
||||
};
|
||||
|
||||
Categories.getCategoriesByPrivilege = function(set, uid, privilege, callback) {
|
||||
Categories.getCategoriesByPrivilege = function (set, uid, privilege, callback) {
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
function (next) {
|
||||
db.getSortedSetRange(set, 0, -1, next);
|
||||
},
|
||||
function(cids, next) {
|
||||
function (cids, next) {
|
||||
privileges.categories.filterCids(privilege, cids, uid, next);
|
||||
},
|
||||
function(cids, next) {
|
||||
function (cids, next) {
|
||||
Categories.getCategories(cids, uid, next);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
Categories.getModerators = function(cid, callback) {
|
||||
Groups.getMembers('cid:' + cid + ':privileges:mods', 0, -1, function(err, uids) {
|
||||
Categories.getModerators = function (cid, callback) {
|
||||
Groups.getMembers('cid:' + cid + ':privileges:mods', 0, -1, function (err, uids) {
|
||||
if (err || !Array.isArray(uids) || !uids.length) {
|
||||
return callback(err, []);
|
||||
}
|
||||
@@ -131,7 +131,7 @@ var privileges = require('./privileges');
|
||||
};
|
||||
|
||||
|
||||
Categories.getCategories = function(cids, uid, callback) {
|
||||
Categories.getCategories = function (cids, uid, callback) {
|
||||
if (!Array.isArray(cids)) {
|
||||
return callback(new Error('[[error:invalid-cid]]'));
|
||||
}
|
||||
@@ -141,19 +141,19 @@ var privileges = require('./privileges');
|
||||
}
|
||||
|
||||
async.parallel({
|
||||
categories: function(next) {
|
||||
categories: function (next) {
|
||||
Categories.getCategoriesData(cids, next);
|
||||
},
|
||||
children: function(next) {
|
||||
children: function (next) {
|
||||
Categories.getChildren(cids, uid, next);
|
||||
},
|
||||
parents: function(next) {
|
||||
parents: function (next) {
|
||||
Categories.getParents(cids, next);
|
||||
},
|
||||
hasRead: function(next) {
|
||||
hasRead: function (next) {
|
||||
Categories.hasReadCategories(cids, uid, next);
|
||||
}
|
||||
}, function(err, results) {
|
||||
}, function (err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -187,7 +187,7 @@ var privileges = require('./privileges');
|
||||
return;
|
||||
}
|
||||
|
||||
category.children.forEach(function(child) {
|
||||
category.children.forEach(function (child) {
|
||||
calculateTopicPostCount(child);
|
||||
postCount += parseInt(child.totalPostCount, 10) || 0;
|
||||
topicCount += parseInt(child.totalTopicCount, 10) || 0;
|
||||
@@ -197,7 +197,7 @@ var privileges = require('./privileges');
|
||||
category.totalTopicCount = topicCount;
|
||||
}
|
||||
|
||||
Categories.getParents = function(cids, callback) {
|
||||
Categories.getParents = function (cids, callback) {
|
||||
var categoriesData;
|
||||
var parentCids;
|
||||
async.waterfall([
|
||||
@@ -207,20 +207,20 @@ var privileges = require('./privileges');
|
||||
function (_categoriesData, next) {
|
||||
categoriesData = _categoriesData;
|
||||
|
||||
parentCids = categoriesData.filter(function(category) {
|
||||
parentCids = categoriesData.filter(function (category) {
|
||||
return category && category.hasOwnProperty('parentCid') && parseInt(category.parentCid, 10);
|
||||
}).map(function(category) {
|
||||
}).map(function (category) {
|
||||
return parseInt(category.parentCid, 10);
|
||||
});
|
||||
|
||||
if (!parentCids.length) {
|
||||
return callback(null, cids.map(function() {return null;}));
|
||||
return callback(null, cids.map(function () {return null;}));
|
||||
}
|
||||
|
||||
Categories.getCategoriesData(parentCids, next);
|
||||
},
|
||||
function (parentData, next) {
|
||||
parentData = categoriesData.map(function(category) {
|
||||
parentData = categoriesData.map(function (category) {
|
||||
return parentData[parentCids.indexOf(parseInt(category.parentCid, 10))];
|
||||
});
|
||||
next(null, parentData);
|
||||
@@ -228,15 +228,15 @@ var privileges = require('./privileges');
|
||||
], callback);
|
||||
};
|
||||
|
||||
Categories.getChildren = function(cids, uid, callback) {
|
||||
var categories = cids.map(function(cid) {
|
||||
Categories.getChildren = function (cids, uid, callback) {
|
||||
var categories = cids.map(function (cid) {
|
||||
return {cid: cid};
|
||||
});
|
||||
|
||||
async.each(categories, function(category, next) {
|
||||
async.each(categories, function (category, next) {
|
||||
getChildrenRecursive(category, uid, next);
|
||||
}, function (err) {
|
||||
callback(err, categories.map(function(c) {
|
||||
callback(err, categories.map(function (c) {
|
||||
return c && c.children;
|
||||
}));
|
||||
});
|
||||
@@ -251,7 +251,7 @@ var privileges = require('./privileges');
|
||||
privileges.categories.filterCids('find', children, uid, next);
|
||||
},
|
||||
function (children, next) {
|
||||
children = children.filter(function(cid) {
|
||||
children = children.filter(function (cid) {
|
||||
return parseInt(category.cid, 10) !== parseInt(cid, 10);
|
||||
});
|
||||
if (!children.length) {
|
||||
@@ -263,15 +263,15 @@ var privileges = require('./privileges');
|
||||
function (childrenData, next) {
|
||||
childrenData = childrenData.filter(Boolean);
|
||||
category.children = childrenData;
|
||||
async.each(category.children, function(child, next) {
|
||||
async.each(category.children, function (child, next) {
|
||||
getChildrenRecursive(child, uid, next);
|
||||
}, next);
|
||||
}
|
||||
], callback);
|
||||
}
|
||||
|
||||
Categories.flattenCategories = function(allCategories, categoryData) {
|
||||
categoryData.forEach(function(category) {
|
||||
Categories.flattenCategories = function (allCategories, categoryData) {
|
||||
categoryData.forEach(function (category) {
|
||||
if (!category) {
|
||||
return;
|
||||
}
|
||||
@@ -292,7 +292,7 @@ var privileges = require('./privileges');
|
||||
* @param categories {array} flat list of categories
|
||||
* @param parentCid {number} start from 0 to build full tree
|
||||
*/
|
||||
Categories.getTree = function(categories, parentCid) {
|
||||
Categories.getTree = function (categories, parentCid) {
|
||||
var tree = [], i = 0, len = categories.length, category;
|
||||
|
||||
for (i; i < len; ++i) {
|
||||
@@ -310,7 +310,7 @@ var privileges = require('./privileges');
|
||||
return tree;
|
||||
};
|
||||
|
||||
Categories.buildForSelect = function(uid, callback) {
|
||||
Categories.buildForSelect = function (uid, callback) {
|
||||
function recursive(category, categoriesData, level) {
|
||||
if (category.link) {
|
||||
return;
|
||||
@@ -321,39 +321,39 @@ var privileges = require('./privileges');
|
||||
category.text = level + bullet + category.name
|
||||
categoriesData.push(category);
|
||||
|
||||
category.children.forEach(function(child) {
|
||||
category.children.forEach(function (child) {
|
||||
recursive(child, categoriesData, ' ' + level);
|
||||
});
|
||||
}
|
||||
Categories.getCategoriesByPrivilege('cid:0:children', uid, 'read', function(err, categories) {
|
||||
Categories.getCategoriesByPrivilege('cid:0:children', uid, 'read', function (err, categories) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var categoriesData = [];
|
||||
|
||||
categories = categories.filter(function(category) {
|
||||
categories = categories.filter(function (category) {
|
||||
return category && !category.link && !parseInt(category.parentCid, 10);
|
||||
});
|
||||
|
||||
categories.forEach(function(category) {
|
||||
categories.forEach(function (category) {
|
||||
recursive(category, categoriesData, '');
|
||||
});
|
||||
callback(null, categoriesData);
|
||||
});
|
||||
};
|
||||
|
||||
Categories.getIgnorers = function(cid, start, stop, callback) {
|
||||
Categories.getIgnorers = function (cid, start, stop, callback) {
|
||||
db.getSortedSetRevRange('cid:' + cid + ':ignorers', start, stop, callback);
|
||||
};
|
||||
|
||||
Categories.filterIgnoringUids = function(cid, uids, callback) {
|
||||
Categories.filterIgnoringUids = function (cid, uids, callback) {
|
||||
async.waterfall([
|
||||
function (next){
|
||||
db.sortedSetScores('cid:' + cid + ':ignorers', uids, next);
|
||||
},
|
||||
function (scores, next) {
|
||||
var readingUids = uids.filter(function(uid, index) {
|
||||
var readingUids = uids.filter(function (uid, index) {
|
||||
return uid && !!scores[index];
|
||||
});
|
||||
next(null, readingUids);
|
||||
|
||||
Reference in New Issue
Block a user