Skip to content

Node.js based forum software built for the modern web

closes #1577

barisusaklieb0a06b777eb
diff --git a/public/src/forum/topic/events.js b/public/src/forum/topic/events.js
index 330f11f79e..04336c0cca 100644
--- a/public/src/forum/topic/events.js
+++ b/public/src/forum/topic/events.js
@@ -113,8 +113,18 @@ define(['forum/topic/browsing', 'forum/topic/postTools', 'forum/topic/threadTool
if (postEl.length) {
postEl.toggleClass('deleted');
-
- postTools.toggle(data.pid, postEl.hasClass('deleted'));
+ var isDeleted = postEl.hasClass('deleted');
+ postTools.toggle(data.pid, isDeleted);
+
+ if (!app.isAdmin && parseInt(data.uid, 10) !== parseInt(app.uid, 10)) {
+ if (isDeleted) {
+ translator.translate('[[topic:post_is_deleted]]', function(translated) {
+ postEl.find('.post-content').html(translated);
+ });
+ } else {
+ postEl.find('.post-content').html(data.content);
+ }
+ }
postTools.updatePostCount();
}
diff --git a/src/postTools.js b/src/postTools.js
index 1e5ef0dfcd..20e8cc272c 100644
--- a/src/postTools.js
+++ b/src/postTools.js
@@ -146,7 +146,7 @@ var winston = require('winston'),
db.incrObjectFieldBy('global', 'postCount', isDelete ? -1 : 1);
- posts.getPostFields(pid, ['tid', 'uid', 'content'], function(err, postData) {
+ posts.getPostFields(pid, ['pid', 'tid', 'uid', 'content'], function(err, postData) {
if (err) {
return callback(err);
}
@@ -170,7 +170,16 @@ var winston = require('winston'),
function(next) {
addOrRemoveFromCategoryRecentPosts(pid, postData.tid, isDelete, next);
}
- ], callback);
+ ], function(err) {
+ if (!isDelete) {
+ PostTools.parse(postData.content, function(err, parsed) {
+ postData.content = parsed;
+ callback(err, postData);
+ });
+ return;
+ }
+ callback(err, postData);
+ });
});
});
});
diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js
index 0ce662b9bd..bfe1489e2b 100644
--- a/src/socket.io/posts.js
+++ b/src/socket.io/posts.js
@@ -188,7 +188,7 @@ function deleteOrRestore(command, socket, data, callback) {
return callback(new Error('[[error:invalid-data]]'));
}
- postTools[command](socket.uid, data.pid, function(err) {
+ postTools[command](socket.uid, data.pid, function(err, postData) {
if(err) {
return callback(err);
}
@@ -196,9 +196,7 @@ function deleteOrRestore(command, socket, data, callback) {
module.parent.exports.emitTopicPostStats();
var eventName = command === 'restore' ? 'event:post_restored' : 'event:post_deleted';
- websockets.server.sockets.in('topic_' + data.tid).emit(eventName, {
- pid: data.pid
- });
+ websockets.server.sockets.in('topic_' + data.tid).emit(eventName, postData);
callback();
});