Files
danbooru/app/components/forum_post_component.rb
evazion c8d27c2719 Fix #4669: Track moderation report status.
* Add ability to mark moderation reports as 'handled' or 'rejected'.
* Automatically mark reports as handled when the comment or forum post
  is deleted.
* Send a dmail to the reporter when their report is handled.
* Don't show the report notice on comments or forum posts when all
  reports against it have been handled or rejected.
* Add a fix script to mark all existing reports for deleted comments,
  forum posts, or dmails as handled.
2022-01-20 20:50:23 -06:00

36 lines
1.3 KiB
Ruby

# frozen_string_literal: true
class ForumPostComponent < ApplicationComponent
attr_reader :forum_post, :original_forum_post_id, :dtext_data, :current_user
delegate :link_to_user, :time_ago_in_words_tagged, :format_text, :data_attributes_for, to: :helpers
with_collection_parameter :forum_post
def self.with_collection(forum_posts, forum_topic:, current_user:)
dtext_data = DText.preprocess(forum_posts.map(&:body))
original_forum_post_id = forum_topic.original_post&.id
forum_posts = forum_posts.includes(:creator, :bulk_update_request)
forum_posts = forum_posts.includes(:pending_moderation_reports) if Pundit.policy(current_user, ModerationReport).can_see_moderation_reports?
super(forum_posts, dtext_data: dtext_data, original_forum_post_id: original_forum_post_id, current_user: current_user)
end
def initialize(forum_post:, original_forum_post_id: nil, dtext_data: nil, current_user: User.anonymous)
super
@forum_post = forum_post
@original_forum_post_id = original_forum_post_id
@dtext_data = dtext_data
@current_user = current_user
end
def render?
policy(forum_post).show_deleted?
end
def reported?
policy(ModerationReport).can_see_moderation_reports? && forum_post.pending_moderation_reports.present?
end
end