Check whether the user can read the replies and allow filtering the reply count in plugins

This commit is contained in:
Ben Lubar
2016-11-08 18:43:26 -06:00
parent ecef0c6ad5
commit 5937fefa39
2 changed files with 10 additions and 1 deletions

View File

@@ -127,6 +127,9 @@ SocketPosts.getReplies = function (socket, pid, callback) {
function (next) { function (next) {
posts.getPidsFromSet('pid:' + pid + ':replies', 0, -1, false, next); posts.getPidsFromSet('pid:' + pid + ':replies', 0, -1, false, next);
}, },
function (pids, next) {
privileges.posts.filter('read', pids, socket.uid, next);
},
function (pids, next) { function (pids, next) {
async.parallel({ async.parallel({
posts: function (next) { posts: function (next) {

View File

@@ -9,6 +9,7 @@ var db = require('../database');
var user = require('../user'); var user = require('../user');
var posts = require('../posts'); var posts = require('../posts');
var meta = require('../meta'); var meta = require('../meta');
var plugins = require('../plugins');
module.exports = function (Topics) { module.exports = function (Topics) {
@@ -133,7 +134,12 @@ module.exports = function (Topics) {
} }
}); });
callback(null, postData); plugins.fireHook('filter:topics.addPostData', {
posts: postData,
uid: uid
}, function (err, data) {
callback(err, data ? data.posts : null);
});
}); });
}; };