mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-20 15:30:39 +01:00
show deleted replies like regular deleted posts
This commit is contained in:
10
src/posts.js
10
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));
|
}(exports));
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ module.exports = function (privileges) {
|
|||||||
function (cids, next) {
|
function (cids, next) {
|
||||||
async.parallel({
|
async.parallel({
|
||||||
isAdmin: async.apply(user.isAdministrator, uid),
|
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),
|
isOwner: async.apply(posts.isOwner, pids, uid),
|
||||||
'topics:read': async.apply(helpers.isUserAllowedTo, 'topics:read', uid, cids),
|
'topics:read': async.apply(helpers.isUserAllowedTo, 'topics:read', uid, cids),
|
||||||
read: async.apply(helpers.isUserAllowedTo, 'read', uid, cids),
|
read: async.apply(helpers.isUserAllowedTo, 'read', uid, cids),
|
||||||
|
|||||||
@@ -122,23 +122,32 @@ SocketPosts.getReplies = function (socket, pid, callback) {
|
|||||||
if (!utils.isNumber(pid)) {
|
if (!utils.isNumber(pid)) {
|
||||||
return callback(new Error('[[error:invalid-data]'));
|
return callback(new Error('[[error:invalid-data]'));
|
||||||
}
|
}
|
||||||
|
var postPrivileges;
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
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) {
|
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) {
|
function (results, next) {
|
||||||
posts.getPostsByPids(pids, socket.uid, 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);
|
||||||
}
|
}
|
||||||
], function (err, postData) {
|
], callback);
|
||||||
if (err) {
|
|
||||||
return callback(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
topics.addPostData(postData, socket.uid, callback);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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.display_post_menu = topicPrivileges.isAdminOrMod || (post.selfPost && !topicData.locked) || ((loggedIn || topicData.postSharing.length) && !post.deleted);
|
||||||
post.ip = topicPrivileges.isAdminOrMod ? post.ip : undefined;
|
post.ip = topicPrivileges.isAdminOrMod ? post.ip : undefined;
|
||||||
|
|
||||||
if (post.deleted && !(topicPrivileges.isAdminOrMod || post.selfPost)) {
|
posts.modifyPostByPrivilege(post, topicPrivileges.isAdminOrMod);
|
||||||
post.content = '[[topic:post_is_deleted]]';
|
|
||||||
if (post.user) {
|
|
||||||
post.user.signature = '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user