getMainPost uses getMainPosts

v1.18.x
barisusakli 11 years ago
parent b858b120da
commit 22fdf9f4ed

@ -308,23 +308,8 @@ var async = require('async'),
};
Topics.getMainPost = function(tid, uid, callback) {
Topics.getTopicField(tid, 'mainPid', function(err, mainPid) {
if (err) {
return callback(err);
}
if (!parseInt(mainPid, 10)) {
return callback(null, []);
}
posts.getPostsByPids([mainPid], function(err, postData) {
if (err) {
return callback(err);
}
if (!Array.isArray(postData) || !postData[0]) {
return callback(null, []);
}
postData[0].index = 0;
Topics.addPostData(postData, uid, callback);
});
Topics.getMainPosts([tid], uid, function(err, mainPosts) {
calllback(err, Array.isArray(mainPosts) && mainPosts.length ? mainPosts[0] : null);
});
};

Loading…
Cancel
Save