mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 06:25:50 +01:00
getMainPost uses getMainPosts
This commit is contained in:
@@ -308,23 +308,8 @@ var async = require('async'),
|
|||||||
};
|
};
|
||||||
|
|
||||||
Topics.getMainPost = function(tid, uid, callback) {
|
Topics.getMainPost = function(tid, uid, callback) {
|
||||||
Topics.getTopicField(tid, 'mainPid', function(err, mainPid) {
|
Topics.getMainPosts([tid], uid, function(err, mainPosts) {
|
||||||
if (err) {
|
calllback(err, Array.isArray(mainPosts) && mainPosts.length ? mainPosts[0] : null);
|
||||||
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);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user