* Let the user see their own username when viewing their own deleted comments. * Don't hide the creator_id field from the comment creator in the API. * Hide the score, do_not_bump_post, and is_sticky fields for deleted comments in the HTML and in the API, unless the user is a moderator. * Hide the "..." popup menu on deleted comments, unless the user is a moderator. This is so that when a user looks at their own comment history, their name isn't hidden from them on their own deleted comments. This may confuse users however into thinking their name is still visible to other users.
52 lines
1.2 KiB
Ruby
52 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class CommentComponent < ApplicationComponent
|
|
attr_reader :comment, :context, :dtext_data, :current_user
|
|
|
|
def initialize(comment:, current_user:, context: nil, dtext_data: nil)
|
|
super
|
|
@comment = comment
|
|
@context = context
|
|
@dtext_data = dtext_data
|
|
@current_user = current_user
|
|
end
|
|
|
|
def dimmed?
|
|
comment.is_deleted? || (!comment.is_sticky? && comment.score <= current_user.comment_threshold / 2.0)
|
|
end
|
|
|
|
def thresholded?
|
|
!comment.is_deleted? && !comment.is_sticky? && comment.score <= current_user.comment_threshold
|
|
end
|
|
|
|
def can_see_creator?
|
|
policy(comment).can_see_creator?
|
|
end
|
|
|
|
def redact_deleted?
|
|
comment.is_deleted? && !policy(comment).can_see_deleted?
|
|
end
|
|
|
|
def votable?
|
|
!comment.is_deleted? || current_user.is_moderator?
|
|
end
|
|
|
|
def upvoted?
|
|
return false if current_user.is_anonymous?
|
|
!!current_vote&.is_positive?
|
|
end
|
|
|
|
def downvoted?
|
|
return false if current_user.is_anonymous?
|
|
!!current_vote&.is_negative?
|
|
end
|
|
|
|
def current_vote
|
|
@current_vote ||= comment.votes.active.find { |v| v.user_id == current_user.id }
|
|
end
|
|
|
|
def reported?
|
|
policy(ModerationReport).can_see_moderation_reports? && comment.pending_moderation_reports.present?
|
|
end
|
|
end
|