From 5937fefa3925afb01a8f158a85f766bbe45072c8 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Tue, 8 Nov 2016 18:43:26 -0600 Subject: [PATCH] Check whether the user can read the replies and allow filtering the reply count in plugins --- src/socket.io/posts.js | 3 +++ src/topics/posts.js | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js index d818f2ee52..30dfa016ee 100644 --- a/src/socket.io/posts.js +++ b/src/socket.io/posts.js @@ -127,6 +127,9 @@ SocketPosts.getReplies = function (socket, pid, callback) { function (next) { posts.getPidsFromSet('pid:' + pid + ':replies', 0, -1, false, next); }, + function (pids, next) { + privileges.posts.filter('read', pids, socket.uid, next); + }, function (pids, next) { async.parallel({ posts: function (next) { diff --git a/src/topics/posts.js b/src/topics/posts.js index 29a77ef203..aadf6bd76b 100644 --- a/src/topics/posts.js +++ b/src/topics/posts.js @@ -9,6 +9,7 @@ var db = require('../database'); var user = require('../user'); var posts = require('../posts'); var meta = require('../meta'); +var plugins = require('../plugins'); 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); + }); }); };