mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 04:25:55 +01:00
closes #2123
This commit is contained in:
@@ -252,25 +252,40 @@ topicsController.get = function(req, res, next) {
|
|||||||
topicsController.teaser = function(req, res, next) {
|
topicsController.teaser = function(req, res, next) {
|
||||||
var tid = req.params.topic_id;
|
var tid = req.params.topic_id;
|
||||||
var uid = req.user ? parseInt(req.user.uid, 10) : 0;
|
var uid = req.user ? parseInt(req.user.uid, 10) : 0;
|
||||||
topics.getLatestUndeletedPid(tid, function(err, pid) {
|
|
||||||
|
if (!utils.isNumber(tid)) {
|
||||||
|
return next(new Error('[[error:invalid-tid]]'));
|
||||||
|
}
|
||||||
|
|
||||||
|
privileges.topics.can('read', tid, uid, function(err, canRead) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pid) {
|
if (!canRead) {
|
||||||
return res.json(404, 'not-found');
|
return res.json(403, '[[error:no-priveges]]');
|
||||||
}
|
}
|
||||||
|
|
||||||
posts.getPostSummaryByPids([pid], uid, {stripTags: false}, function(err, posts) {
|
topics.getLatestUndeletedPid(tid, function(err, pid) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Array.isArray(posts) || !posts.length) {
|
if (!pid) {
|
||||||
return res.json(404, 'not-found');
|
return res.json(404, 'not-found');
|
||||||
}
|
}
|
||||||
|
|
||||||
res.json(posts[0]);
|
posts.getPostSummaryByPids([pid], uid, {stripTags: 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]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user