getTopicWithPosts change, fix feeds

This commit is contained in:
barisusakli
2016-01-21 20:51:07 +02:00
parent 07c55ee859
commit dbc04cb4a2
3 changed files with 148 additions and 154 deletions

View File

@@ -36,12 +36,12 @@ topicsController.get = function(req, res, callback) {
user.getSettings(req.uid, next);
},
topic: function(next) {
topics.getTopicFields(tid, ['slug', 'postcount', 'deleted'], next);
topics.getTopicData(tid, next);
}
}, next);
},
function (results, next) {
if (!results.topic.slug) {
if (!results.topic) {
return callback();
}
@@ -106,26 +106,19 @@ topicsController.get = function(req, res, callback) {
currentPage = Math.max(1, Math.ceil(index / settings.postsPerPage));
}
var start = (currentPage - 1) * settings.postsPerPage + postIndex,
stop = start + settings.postsPerPage - 1;
var start = (currentPage - 1) * settings.postsPerPage + postIndex;
var stop = start + settings.postsPerPage - 1;
topics.getTopicWithPosts(tid, set, req.uid, start, stop, reverse, function (err, topicData) {
if (err && err.message === '[[error:no-topic]]' && !topicData) {
return callback();
}
topics.getTopicWithPosts(results.topic, set, req.uid, start, stop, reverse, next);
},
function (topicData, next) {
if (topicData.category.disabled) {
return callback();
}
if (err && !topicData) {
return next(err);
}
topics.modifyByPrivilege(topicData.posts, userPrivileges);
if (topicData.category.disabled) {
return callback();
}
topics.modifyByPrivilege(topicData.posts, results.privileges);
plugins.fireHook('filter:controllers.topic.get', {topicData: topicData, uid: req.uid}, next);
});
plugins.fireHook('filter:controllers.topic.get', {topicData: topicData, uid: req.uid}, next);
},
function (data, next) {