Files
danbooru/app/controllers/moderation_reports_controller.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

41 lines
1.4 KiB
Ruby

# frozen_string_literal: true
class ModerationReportsController < ApplicationController
respond_to :html, :xml, :json, :js
rate_limit :create, rate: 1.0/1.minute, burst: 10
def new
@moderation_report = authorize ModerationReport.new(permitted_attributes(ModerationReport))
respond_with(@moderation_report)
end
def index
@moderation_reports = authorize ModerationReport.visible(CurrentUser.user).paginated_search(params, count_pages: true)
@moderation_reports = @moderation_reports.includes(:creator, :model) if request.format.html?
respond_with(@moderation_reports)
end
def show
authorize ModerationReport
redirect_to moderation_reports_path(search: { id: params[:id] })
end
def create
@moderation_report = authorize ModerationReport.new(creator: CurrentUser.user, **permitted_attributes(ModerationReport))
@moderation_report.save
flash.now[:notice] = @moderation_report.valid? ? "Report submitted" : @moderation_report.errors.full_messages.join("; ")
respond_with(@moderation_report)
end
def update
@moderation_report = authorize ModerationReport.find(params[:id])
@moderation_report.update(permitted_attributes(@moderation_report))
flash.now[:notice] = @moderation_report.valid? ? "Report updated" : @moderation_report.errors.full_messages.join("; ")
respond_with(@moderation_report)
end
end