From eb0a06b777eb3850e290ef73663132b60cae7a5a Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 27 May 2014 14:53:47 -0400 Subject: [PATCH] closes #1577 --- public/src/forum/topic/events.js | 14 ++++++++++++-- src/postTools.js | 13 +++++++++++-- src/socket.io/posts.js | 6 ++---- 3 files changed, 25 insertions(+), 8 deletions(-) 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(); });