mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 06:25:50 +01:00
Fix space-before-function-paren linter rule
This commit is contained in:
128
src/topics.js
128
src/topics.js
@@ -12,7 +12,7 @@ var categories = require('./categories');
|
||||
var privileges = require('./privileges');
|
||||
var social = require('./social');
|
||||
|
||||
(function(Topics) {
|
||||
(function (Topics) {
|
||||
|
||||
require('./topics/data')(Topics);
|
||||
require('./topics/create')(Topics);
|
||||
@@ -30,19 +30,19 @@ var social = require('./social');
|
||||
require('./topics/tools')(Topics);
|
||||
require('./topics/thumb')(Topics);
|
||||
|
||||
Topics.exists = function(tid, callback) {
|
||||
Topics.exists = function (tid, callback) {
|
||||
db.isSortedSetMember('topics:tid', tid, callback);
|
||||
};
|
||||
|
||||
Topics.getPageCount = function(tid, uid, callback) {
|
||||
Topics.getTopicField(tid, 'postcount', function(err, postCount) {
|
||||
Topics.getPageCount = function (tid, uid, callback) {
|
||||
Topics.getTopicField(tid, 'postcount', function (err, postCount) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
if (!parseInt(postCount, 10)) {
|
||||
return callback(null, 1);
|
||||
}
|
||||
user.getSettings(uid, function(err, settings) {
|
||||
user.getSettings(uid, function (err, settings) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -52,19 +52,19 @@ var social = require('./social');
|
||||
});
|
||||
};
|
||||
|
||||
Topics.getTidPage = function(tid, uid, callback) {
|
||||
Topics.getTidPage = function (tid, uid, callback) {
|
||||
if(!tid) {
|
||||
return callback(new Error('[[error:invalid-tid]]'));
|
||||
}
|
||||
|
||||
async.parallel({
|
||||
index: function(next) {
|
||||
index: function (next) {
|
||||
categories.getTopicIndex(tid, next);
|
||||
},
|
||||
settings: function(next) {
|
||||
settings: function (next) {
|
||||
user.getSettings(uid, next);
|
||||
}
|
||||
}, function(err, results) {
|
||||
}, function (err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -72,32 +72,32 @@ var social = require('./social');
|
||||
});
|
||||
};
|
||||
|
||||
Topics.getTopicsFromSet = function(set, uid, start, stop, callback) {
|
||||
Topics.getTopicsFromSet = function (set, uid, start, stop, callback) {
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
function (next) {
|
||||
db.getSortedSetRevRange(set, start, stop, next);
|
||||
},
|
||||
function(tids, next) {
|
||||
function (tids, next) {
|
||||
Topics.getTopics(tids, uid, next);
|
||||
},
|
||||
function(topics, next) {
|
||||
function (topics, next) {
|
||||
next(null, {topics: topics, nextStart: stop + 1});
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
Topics.getTopics = function(tids, uid, callback) {
|
||||
Topics.getTopics = function (tids, uid, callback) {
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
function (next) {
|
||||
privileges.topics.filterTids('read', tids, uid, next);
|
||||
},
|
||||
function(tids, next) {
|
||||
function (tids, next) {
|
||||
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, []);
|
||||
}
|
||||
@@ -105,14 +105,14 @@ var social = require('./social');
|
||||
var uids, cids, topics;
|
||||
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
function (next) {
|
||||
Topics.getTopicsData(tids, next);
|
||||
},
|
||||
function(_topics, next) {
|
||||
function (_topics, next) {
|
||||
function mapFilter(array, field) {
|
||||
return array.map(function(topic) {
|
||||
return array.map(function (topic) {
|
||||
return topic && topic[field] && topic[field].toString();
|
||||
}).filter(function(value, index, array) {
|
||||
}).filter(function (value, index, array) {
|
||||
return utils.isNumber(value) && array.indexOf(value) === index;
|
||||
});
|
||||
}
|
||||
@@ -122,30 +122,30 @@ var social = require('./social');
|
||||
cids = mapFilter(topics, 'cid');
|
||||
|
||||
async.parallel({
|
||||
users: function(next) {
|
||||
users: function (next) {
|
||||
user.getUsersFields(uids, ['uid', 'username', 'fullname', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned', 'status'], next);
|
||||
},
|
||||
categories: function(next) {
|
||||
categories: function (next) {
|
||||
categories.getCategoriesFields(cids, ['cid', 'name', 'slug', 'icon', 'image', 'bgColor', 'color', 'disabled'], next);
|
||||
},
|
||||
hasRead: function(next) {
|
||||
hasRead: function (next) {
|
||||
Topics.hasReadTopics(tids, uid, next);
|
||||
},
|
||||
isIgnored: function(next) {
|
||||
isIgnored: function (next) {
|
||||
Topics.isIgnoring(tids, uid, next);
|
||||
},
|
||||
bookmarks: function(next) {
|
||||
bookmarks: function (next) {
|
||||
Topics.getUserBookmarks(tids, uid, next);
|
||||
},
|
||||
teasers: function(next) {
|
||||
teasers: function (next) {
|
||||
Topics.getTeasers(topics, next);
|
||||
},
|
||||
tags: function(next) {
|
||||
tags: function (next) {
|
||||
Topics.getTopicsTagsObjects(tids, next);
|
||||
}
|
||||
}, next);
|
||||
},
|
||||
function(results, next) {
|
||||
function (results, next) {
|
||||
var users = _.object(uids, results.users);
|
||||
var categories = _.object(cids, results.categories);
|
||||
|
||||
@@ -169,19 +169,19 @@ var social = require('./social');
|
||||
}
|
||||
}
|
||||
|
||||
topics = topics.filter(function(topic) {
|
||||
topics = topics.filter(function (topic) {
|
||||
return topic && topic.category && !topic.category.disabled;
|
||||
});
|
||||
|
||||
plugins.fireHook('filter:topics.get', {topics: topics, uid: uid}, next);
|
||||
},
|
||||
function(data, next) {
|
||||
function (data, next) {
|
||||
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({
|
||||
@@ -192,12 +192,12 @@ var social = require('./social');
|
||||
isIgnoring: async.apply(Topics.isIgnoring, [topicData.tid], uid),
|
||||
bookmark: async.apply(Topics.getUserBookmark, topicData.tid, uid),
|
||||
postSharing: async.apply(social.getActivePostSharing),
|
||||
related: function(next) {
|
||||
related: function (next) {
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
function (next) {
|
||||
Topics.getTopicTagsObjects(topicData.tid, next);
|
||||
},
|
||||
function(tags, next) {
|
||||
function (tags, next) {
|
||||
topicData.tags = tags;
|
||||
Topics.getRelatedTopics(topicData, uid, next);
|
||||
}
|
||||
@@ -233,10 +233,10 @@ var social = require('./social');
|
||||
|
||||
function getMainPostAndReplies(topic, set, uid, start, stop, reverse, callback) {
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
function (next) {
|
||||
posts.getPidsFromSet(set, start, stop, reverse, next);
|
||||
},
|
||||
function(pids, next) {
|
||||
function (pids, next) {
|
||||
if ((!Array.isArray(pids) || !pids.length) && !topic.mainPid) {
|
||||
return callback(null, []);
|
||||
}
|
||||
@@ -246,7 +246,7 @@ var social = require('./social');
|
||||
}
|
||||
posts.getPostsByPids(pids, uid, next);
|
||||
},
|
||||
function(posts, next) {
|
||||
function (posts, next) {
|
||||
if (!posts.length) {
|
||||
return next(null, []);
|
||||
}
|
||||
@@ -263,31 +263,31 @@ var social = require('./social');
|
||||
], callback);
|
||||
}
|
||||
|
||||
Topics.getMainPost = function(tid, uid, callback) {
|
||||
Topics.getMainPosts([tid], uid, function(err, mainPosts) {
|
||||
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) {
|
||||
Topics.getTopicsFields(tids, ['mainPid'], function (err, topicData) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var mainPids = topicData.map(function(topic) {
|
||||
var mainPids = topicData.map(function (topic) {
|
||||
return topic && topic.mainPid;
|
||||
});
|
||||
callback(null, mainPids);
|
||||
});
|
||||
};
|
||||
|
||||
Topics.getMainPosts = function(tids, uid, callback) {
|
||||
Topics.getMainPids(tids, function(err, mainPids) {
|
||||
Topics.getMainPosts = function (tids, uid, callback) {
|
||||
Topics.getMainPids(tids, function (err, mainPids) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -296,11 +296,11 @@ var social = require('./social');
|
||||
};
|
||||
|
||||
function getMainPosts(mainPids, uid, callback) {
|
||||
posts.getPostsByPids(mainPids, uid, function(err, postData) {
|
||||
posts.getPostsByPids(mainPids, uid, function (err, postData) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
postData.forEach(function(post) {
|
||||
postData.forEach(function (post) {
|
||||
if (post) {
|
||||
post.index = 0;
|
||||
}
|
||||
@@ -313,28 +313,28 @@ var social = require('./social');
|
||||
db.sortedSetScore('tid:' + tid + ':bookmarks', uid, callback);
|
||||
};
|
||||
|
||||
Topics.getUserBookmarks = function(tids, uid, callback) {
|
||||
Topics.getUserBookmarks = function (tids, uid, callback) {
|
||||
if (!parseInt(uid, 10)) {
|
||||
return callback(null, tids.map(function() {
|
||||
return callback(null, tids.map(function () {
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
db.sortedSetsScore(tids.map(function(tid) {
|
||||
db.sortedSetsScore(tids.map(function (tid) {
|
||||
return 'tid:' + tid + ':bookmarks';
|
||||
}), uid, callback);
|
||||
};
|
||||
|
||||
Topics.setUserBookmark = function(tid, uid, index, callback) {
|
||||
Topics.setUserBookmark = function (tid, uid, index, callback) {
|
||||
db.sortedSetAdd('tid:' + tid + ':bookmarks', index, uid, callback);
|
||||
};
|
||||
|
||||
Topics.isLocked = function(tid, callback) {
|
||||
Topics.getTopicField(tid, 'locked', function(err, locked) {
|
||||
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,
|
||||
@@ -345,35 +345,35 @@ var social = require('./social');
|
||||
}
|
||||
};
|
||||
|
||||
Topics.getTopicBookmarks = function(tid, callback) {
|
||||
Topics.getTopicBookmarks = function (tid, callback) {
|
||||
db.getSortedSetRangeWithScores(['tid:' + tid + ':bookmarks'], 0, -1, callback);
|
||||
};
|
||||
|
||||
Topics.updateTopicBookmarks = function(tid, pids, callback) {
|
||||
Topics.updateTopicBookmarks = function (tid, pids, callback) {
|
||||
var maxIndex;
|
||||
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
function (next) {
|
||||
Topics.getPostCount(tid, next);
|
||||
},
|
||||
function(postcount, next) {
|
||||
function (postcount, next) {
|
||||
maxIndex = postcount;
|
||||
Topics.getTopicBookmarks(tid, next);
|
||||
},
|
||||
function(bookmarks, next) {
|
||||
var forkedPosts = pids.map(function(pid) {
|
||||
function (bookmarks, next) {
|
||||
var forkedPosts = pids.map(function (pid) {
|
||||
return {pid: pid, tid: tid};
|
||||
});
|
||||
|
||||
var uidData = bookmarks.map(function(bookmark) {
|
||||
var uidData = bookmarks.map(function (bookmark) {
|
||||
return {
|
||||
uid: bookmark.value,
|
||||
bookmark: bookmark.score
|
||||
};
|
||||
});
|
||||
|
||||
async.eachLimit(uidData, 50, function(data, next) {
|
||||
posts.getPostIndices(forkedPosts, data.uid, function(err, postIndices) {
|
||||
async.eachLimit(uidData, 50, function (data, next) {
|
||||
posts.getPostIndices(forkedPosts, data.uid, function (err, postIndices) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
@@ -393,7 +393,7 @@ var social = require('./social');
|
||||
});
|
||||
}, next);
|
||||
}
|
||||
], function(err){
|
||||
], function (err){
|
||||
callback(err);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user