diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl
index 63c4771783..9882cab6c7 100644
--- a/public/templates/topic.tpl
+++ b/public/templates/topic.tpl
@@ -9,7 +9,7 @@
--
+
-
@@ -210,6 +210,14 @@
}
});
}
+
+ // Fix delete state for this thread's posts
+ var postEls = document.querySelectorAll('#post-container li[data-deleted]');
+ for(var x=0,numPosts=postEls.length;x
\ No newline at end of file
diff --git a/src/posts.js b/src/posts.js
index 2cd4b5d08e..2dd84fbe85 100644
--- a/src/posts.js
+++ b/src/posts.js
@@ -23,29 +23,32 @@ marked.setOptions({
function generateThread() {
if (!post_data || !user_data || !thread_data || !vote_data || !viewer_data) return;
- var posts = [];
+ var posts = [],
+ manage_content = viewer_data.reputation >= config.privilege_thresholds.manage_content;
for (var i=0, ii= post_data.pid.length; i= config.privilege_thresholds.manage_content) ? 'show' : 'none',
- 'edited-class': post_data.editor[i] !== null ? '' : 'none',
- 'editor': post_data.editor[i] !== null ? user_data[post_data.editor[i]].username : '',
- 'relativeEditTime': post_data.editTime !== null ? utils.relativeTime(post_data.editTime[i]) : '',
- 'deleted-class': post_data.deleted[i] === '1' ? 'deleted' : ''
- });
+ if (post_data.deleted[i] === null || (post_data.deleted[i] === '1' && manage_content)) {
+ posts.push({
+ 'pid' : pid,
+ 'uid' : uid,
+ 'content' : marked(post_data.content[i] || ''),
+ 'post_rep' : post_data.reputation[i] || 0,
+ 'timestamp' : post_data.timestamp[i],
+ 'relativeTime': utils.relativeTime(post_data.timestamp[i]),
+ 'username' : user_data[uid].username || 'anonymous',
+ 'user_rep' : user_data[uid].reputation || 0,
+ 'gravatar' : user_data[uid].picture,
+ 'fav_star_class' : vote_data[pid] ? 'icon-star' : 'icon-star-empty',
+ 'display_moderator_tools': (uid == current_user || manage_content) ? 'show' : 'none',
+ 'edited-class': post_data.editor[i] !== null ? '' : 'none',
+ 'editor': post_data.editor[i] !== null ? user_data[post_data.editor[i]].username : '',
+ 'relativeEditTime': post_data.editTime !== null ? utils.relativeTime(post_data.editTime[i]) : '',
+ 'deleted': post_data.deleted[i] || '0'
+ });
+ }
}
callback({
@@ -331,4 +334,23 @@ marked.setOptions({
}
});
}
+
+ Posts.restore = function(uid, pid) {
+ RDB.mget(['pid:' + pid + ':tid', 'pid:' + pid + ':uid'], function(err, results) {
+ var tid = results[0],
+ author = results[1],
+ success = function() {
+ RDB.del('pid:' + pid + ':deleted');
+
+ io.sockets.in('topic_' + tid).emit('event:post_restored', { pid: pid });
+ };
+
+ if (uid === author) success();
+ else {
+ user.getUserField(uid, 'reputation', function(reputation) {
+ if (reputation >= config.privilege_thresholds.manage_content) success();
+ });
+ }
+ });
+ }
}(exports));
\ No newline at end of file