Node.js based forum software built for the modern web
show deleted replies like regular deleted posts
barisusakli96d05b58d4dc
diff --git a/src/posts.js b/src/posts.jsindex 975846859b..047917cb5f 100644--- a/src/posts.js+++ b/src/posts.js@@ -260,4 +260,14 @@ var plugins = require('./plugins');});};+ Posts.modifyPostByPrivilege = function (post, isAdminOrMod) {+ if (post.deleted && !(isAdminOrMod || post.selfPost)) {+ post.content = '[[topic:post_is_deleted]]';+ if (post.user) {+ post.user.signature = '';+ }+ }+ };++}(exports));diff --git a/src/privileges/posts.js b/src/privileges/posts.jsindex dbed332b71..d68edc6e14 100644--- a/src/privileges/posts.js+++ b/src/privileges/posts.js@@ -26,7 +26,7 @@ module.exports = function (privileges) {function (cids, next) {async.parallel({isAdmin: async.apply(user.isAdministrator, uid),- isModerator: async.apply(posts.isModerator, pids, uid),+ isModerator: async.apply(user.isModerator, uid, cids),isOwner: async.apply(posts.isOwner, pids, uid),'topics:read': async.apply(helpers.isUserAllowedTo, 'topics:read', uid, cids),read: async.apply(helpers.isUserAllowedTo, 'read', uid, cids),diff --git a/src/socket.io/posts.js b/src/socket.io/posts.jsindex 781970f11f..d818f2ee52 100644--- a/src/socket.io/posts.js+++ b/src/socket.io/posts.js@@ -122,23 +122,32 @@ SocketPosts.getReplies = function (socket, pid, callback) {if (!utils.isNumber(pid)) {return callback(new Error('[[error:invalid-data]'));}+ var postPrivileges;async.waterfall([function (next) {posts.getPidsFromSet('pid:' + pid + ':replies', 0, -1, false, next);},function (pids, next) {- privileges.posts.filter('read', pids, socket.uid, next);+ async.parallel({+ posts: function (next) {+ posts.getPostsByPids(pids, socket.uid, next);+ },+ privileges: function (next) {+ privileges.posts.get(pids, socket.uid, next);+ }+ }, next);},- function (pids, next) {- posts.getPostsByPids(pids, socket.uid, next);- }- ], function (err, postData) {- if (err) {- return callback(err);+ function (results, next) {+ postPrivileges = results.privileges;+ topics.addPostData(results.posts, socket.uid, next);+ },+ function (postData, next) {+ postData.forEach(function (postData) {+ posts.modifyPostByPrivilege(postData, postPrivileges.isAdminOrMod);+ });+ next(null, postData);}-- topics.addPostData(postData, socket.uid, callback);- });+ ], callback);};diff --git a/src/topics/posts.js b/src/topics/posts.jsindex c5140f633a..29a77ef203 100644--- a/src/topics/posts.js+++ b/src/topics/posts.js@@ -148,12 +148,7 @@ module.exports = function (Topics) {post.display_post_menu = topicPrivileges.isAdminOrMod || (post.selfPost && !topicData.locked) || ((loggedIn || topicData.postSharing.length) && !post.deleted);post.ip = topicPrivileges.isAdminOrMod ? post.ip : undefined;- if (post.deleted && !(topicPrivileges.isAdminOrMod || post.selfPost)) {- post.content = '[[topic:post_is_deleted]]';- if (post.user) {- post.user.signature = '';- }- }+ posts.modifyPostByPrivilege(post, topicPrivileges.isAdminOrMod);}});};