mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-31 19:15:58 +01:00
closes #1422
This commit is contained in:
@@ -9,6 +9,7 @@ var topicsController = {},
|
||||
user = require('./../user'),
|
||||
meta = require('./../meta'),
|
||||
topics = require('./../topics'),
|
||||
posts = require('../posts'),
|
||||
threadTools = require('./../threadTools'),
|
||||
utils = require('./../../public/src/utils');
|
||||
|
||||
@@ -181,4 +182,29 @@ topicsController.get = function(req, res, next) {
|
||||
});
|
||||
};
|
||||
|
||||
topicsController.teaser = function(req, res, next) {
|
||||
var tid = req.params.topic_id;
|
||||
topics.getLatestUndeletedPid(tid, function(err, pid) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if (!pid) {
|
||||
return res.json(404, 'not-found');
|
||||
}
|
||||
|
||||
posts.getPostSummaryByPids([pid], false, function(err, posts) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if (!Array.isArray(posts) || !posts.length) {
|
||||
return res.json(404, 'not-found');
|
||||
}
|
||||
|
||||
res.json(posts[0]);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = topicsController;
|
||||
|
||||
Reference in New Issue
Block a user