mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-06 23:56:04 +02:00
dont show flag on deleted posts dont allow flag on deleted posts dont allow upvote downvote favourite on deleted posts
This commit is contained in:
@@ -20,10 +20,11 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com
|
||||
PostTools.toggle = function(pid, isDeleted) {
|
||||
var postEl = $('#post-container li[data-pid="' + pid + '"]');
|
||||
|
||||
postEl.find('.quote, .favourite, .post_reply, .chat').toggleClass('hidden', isDeleted);
|
||||
postEl.find('.quote, .favourite, .post_reply, .chat, .flag').toggleClass('hidden', isDeleted);
|
||||
postEl.find('.purge').toggleClass('hidden', !isDeleted);
|
||||
postEl.find('.delete .i').toggleClass('fa-trash-o', !isDeleted).toggleClass('fa-history', isDeleted);
|
||||
postEl.find('.delete span').translateHtml(isDeleted ? ' [[topic:restore]]' : ' [[topic:delete]]');
|
||||
|
||||
};
|
||||
|
||||
PostTools.updatePostCount = function() {
|
||||
|
||||
@@ -99,11 +99,22 @@ function favouriteCommand(command, eventName, socket, data, callback) {
|
||||
if(!data || !data.pid || !data.room_id) {
|
||||
return;
|
||||
}
|
||||
posts.exists(data.pid, function(err, exists) {
|
||||
if (err || !exists) {
|
||||
async.parallel({
|
||||
exists: function(next) {
|
||||
posts.exists(data.pid, next);
|
||||
},
|
||||
deleted: function(next) {
|
||||
posts.getPostField(data.pid, 'deleted', next);
|
||||
}
|
||||
}, function(err, results) {
|
||||
if (err || !results.exists) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (parseInt(results.deleted, 10) === 1) {
|
||||
return callback(new Error('[[error:post-deleted]]'));
|
||||
}
|
||||
|
||||
favourites[command](data.pid, socket.uid, function(err, result) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
@@ -301,9 +312,12 @@ SocketPosts.flag = function(socket, pid, callback) {
|
||||
}
|
||||
userName = userData.username;
|
||||
|
||||
posts.getPostFields(pid, ['tid', 'uid', 'content'], next);
|
||||
posts.getPostFields(pid, ['tid', 'uid', 'content', 'deleted'], next);
|
||||
},
|
||||
function(postData, next) {
|
||||
if (parseInt(postData.deleted) === 1) {
|
||||
return next(new Error('[[error:post-deleted]]'));
|
||||
}
|
||||
post = postData;
|
||||
topics.getTopicField(postData.tid, 'title', next);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user