Let users see when a post has deleted comments. Show normal users a '[deleted]' placeholder when a comment is deleted. Show the full comment to moderators. Also fix it so that the comment creator can't edit or undelete deleted comments, and users can't vote on or report deleted comments. Finally, hide the creator_id, updater_id, and body of deleted comments in the API.
87 lines
3.8 KiB
Plaintext
87 lines
3.8 KiB
Plaintext
<a name="comment-<%= comment.id %>"></a>
|
|
<article id="comment_<%= comment.id %>" class="comment message"
|
|
data-id="<%= comment.id %>"
|
|
data-post-id="<%= comment.post_id %>"
|
|
data-creator-id="<%= comment.creator_id unless redact_deleted? %>"
|
|
data-updater-id="<%= comment.updater_id unless redact_deleted? %>"
|
|
data-score="<%= comment.score %>"
|
|
data-do-not-bump-post="<%= comment.do_not_bump_post? %>"
|
|
data-is-deleted="<%= comment.is_deleted? %>"
|
|
data-is-sticky="<%= comment.is_sticky? %>"
|
|
data-is-dimmed="<%= dimmed? %>"
|
|
data-is-thresholded="<%= thresholded? %>"
|
|
data-is-reported="<%= has_moderation_reports? %>"
|
|
data-is-voted="<%= comment.voted_by?(current_user) %>">
|
|
<div class="author">
|
|
<div class="author-name">
|
|
<% if redact_deleted? %>
|
|
[deleted]
|
|
<% else %>
|
|
<%= link_to_user comment.creator %>
|
|
<% if comment.is_deleted? %>
|
|
(deleted)
|
|
<% end %>
|
|
<% end %>
|
|
</div>
|
|
<%= link_to time_ago_in_words_tagged(comment.created_at), post_path(comment.post, anchor: "comment_#{comment.id}"), class: "message-timestamp" %>
|
|
</div>
|
|
<div class="content">
|
|
<% if thresholded? %>
|
|
<%= link_to "[hidden]", "javascript:void(0)", class: "unhide-comment-link" %>
|
|
<% end %>
|
|
|
|
<%= tag.div class: "body prose", style: ("display: none;" if thresholded?) do %>
|
|
<% if redact_deleted? %>
|
|
<p>[deleted]</p>
|
|
<% else %>
|
|
<%= format_text(comment.body, data: dtext_data) %>
|
|
<% end %>
|
|
|
|
<%= render "application/update_notice", record: comment %>
|
|
<% end %>
|
|
|
|
<menu>
|
|
<% if policy(comment).reply? %>
|
|
<% if context == :index_by_comment %>
|
|
<li><%= link_to "Reply", new_comment_path(id: comment, comment: { post_id: comment.post_id }), class: "reply-link" %></li>
|
|
<% else %>
|
|
<li><%= link_to "Reply", new_comment_path(id: comment, comment: { post_id: comment.post_id }), class: "reply-link", remote: true %></li>
|
|
<% end %>
|
|
<% end %>
|
|
|
|
<% if policy(comment).update? %>
|
|
<% if comment.is_deleted? %>
|
|
<li><%= link_to "Undelete", undelete_comment_path(comment.id), method: :post, remote: true %></li>
|
|
<% else %>
|
|
<li><%= link_to "Delete", comment_path(comment.id), "data-confirm": "Are you sure you want to delete this comment?", method: :delete, remote: true %></li>
|
|
<% end %>
|
|
<li><%= link_to "Edit", edit_comment_path(comment.id), id: "edit_comment_link_#{comment.id}", class: "edit_comment_link" %></li>
|
|
<% end %>
|
|
|
|
<% if policy(comment).vote? %>
|
|
<li class="comment-vote-up-link">
|
|
<%= link_to "Vote up", comment_comment_votes_path(comment_id: comment.id, score: "up"), method: :post, remote: true %>
|
|
</li>
|
|
<li class="comment-vote-down-link">
|
|
<%= link_to "Vote down", comment_comment_votes_path(comment_id: comment.id, score: "down"), method: :post, remote: true %>
|
|
</li>
|
|
<li class="comment-unvote-link">
|
|
<%= link_to "Unvote", comment_comment_votes_path(comment_id: comment.id), method: :delete, remote: true %>
|
|
</li>
|
|
<% end %>
|
|
|
|
<% if policy(comment).reportable? %>
|
|
<li><%= link_to "Report", new_moderation_report_path(moderation_report: { model_type: "Comment", model_id: comment.id }), remote: true %></li>
|
|
<% end %>
|
|
|
|
<% if has_moderation_reports? %>
|
|
<li class="moderation-report-notice">This comment has been reported! (<%= link_to pluralize(comment.moderation_reports.length, "report"), moderation_reports_path(search: { model_type: "Comment", model_id: comment.id }) %>)</li>
|
|
<% end %>
|
|
</menu>
|
|
|
|
<% if policy(comment).update? %>
|
|
<%= render "comments/form", comment: comment, hidden: true %>
|
|
<% end %>
|
|
</div>
|
|
</article>
|