src/topics.js cleanup

This commit is contained in:
barisusakli
2014-11-11 19:47:56 -05:00
parent c9f990bb72
commit fa5ac04cd3
6 changed files with 184 additions and 198 deletions

View File

@@ -31,19 +31,18 @@ module.exports = function(Topics) {
Topics.getTopicPosts = function(tid, set, start, end, uid, reverse, callback) {
callback = callback || function() {};
posts.getPostsByTid(tid, set, start, end, uid, reverse, function(err, postData) {
if(err) {
if (err) {
return callback(err);
}
if (Array.isArray(postData) && !postData.length) {
return callback(null, []);
}
Topics.addPostData(postData, uid, callback);
});
};
Topics.addPostData = function(postData, uid, callback) {
if (!Array.isArray(postData) || !postData.length) {
return callback(null, []);
}
var pids = postData.map(function(post) {
return post && post.pid;
});