comments: rework deleted comments.
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.
This commit is contained in:
@@ -1,27 +1,26 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CommentComponent < ApplicationComponent
|
||||
attr_reader :comment, :context, :dtext_data, :show_deleted, :current_user
|
||||
attr_reader :comment, :context, :dtext_data, :current_user
|
||||
delegate :link_to_user, :time_ago_in_words_tagged, :format_text, to: :helpers
|
||||
|
||||
def initialize(comment:, current_user:, context: nil, dtext_data: nil, show_deleted: false)
|
||||
def initialize(comment:, current_user:, context: nil, dtext_data: nil)
|
||||
@comment = comment
|
||||
@context = context
|
||||
@dtext_data = dtext_data
|
||||
@show_deleted = show_deleted
|
||||
@current_user = current_user
|
||||
end
|
||||
|
||||
def render?
|
||||
!comment.is_deleted? || show_deleted || current_user.is_moderator?
|
||||
end
|
||||
|
||||
def dimmed?
|
||||
!comment.is_sticky? && comment.score < current_user.comment_threshold/2.0
|
||||
comment.is_deleted? || (!comment.is_sticky? && comment.score < current_user.comment_threshold/2.0)
|
||||
end
|
||||
|
||||
def thresholded?
|
||||
!comment.is_sticky? && comment.score < current_user.comment_threshold
|
||||
!comment.is_deleted? && !comment.is_sticky? && comment.score < current_user.comment_threshold
|
||||
end
|
||||
|
||||
def redact_deleted?
|
||||
comment.is_deleted? && !policy(comment).can_see_deleted?
|
||||
end
|
||||
|
||||
def has_moderation_reports?
|
||||
|
||||
Reference in New Issue
Block a user