|
|
@ -28,23 +28,6 @@ module.exports = function(Topics) {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
function(tids, next) {
|
|
|
|
function(tids, next) {
|
|
|
|
getTopics(tids, uid, count, next);
|
|
|
|
getTopics(tids, uid, count, next);
|
|
|
|
},
|
|
|
|
|
|
|
|
function(topics, next) {
|
|
|
|
|
|
|
|
var tids = topics.map(function(topic) {
|
|
|
|
|
|
|
|
return topic.tid;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
privileges.topics.filter('read', tids, uid, function(err, tids) {
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
return next(err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
topics = topics.filter(function(topic) {
|
|
|
|
|
|
|
|
return tids.indexOf(topic.tid) !== -1;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
next(null, topics);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
], callback);
|
|
|
|
], callback);
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -65,13 +48,19 @@ module.exports = function(Topics) {
|
|
|
|
return callback(err);
|
|
|
|
return callback(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
topics = topics.sort(function(a, b) {
|
|
|
|
tids = topics.sort(function(a, b) {
|
|
|
|
return b.postcount - a.postcount;
|
|
|
|
return b.postcount - a.postcount;
|
|
|
|
}).slice(0, count).map(function(topic) {
|
|
|
|
}).slice(0, count).map(function(topic) {
|
|
|
|
return topic.tid;
|
|
|
|
return topic.tid;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
Topics.getTopicsByTids(topics, uid, callback);
|
|
|
|
privileges.topics.filter('read', tids, uid, function(err, tids) {
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
return callback(err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Topics.getTopicsByTids(tids, uid, callback);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|