BigW Consortium Gitlab

abuse_reports_controller.rb 716 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11
class AbuseReportsController < ApplicationController
  def new
    @abuse_report = AbuseReport.new
    @abuse_report.user_id = params[:user_id]
  end

  def create
    @abuse_report = AbuseReport.new(report_params)
    @abuse_report.reporter = current_user

    if @abuse_report.save
12
      if current_application_settings.admin_notification_email.present?
Valery Sizov committed
13
        AbuseReportMailer.notify(@abuse_report.id).deliver_later
14
      end
15 16 17

      message = "Thank you for your report. A GitLab administrator will look into it shortly."
      redirect_to root_path, notice: message
18 19 20 21 22 23 24 25 26 27 28
    else
      render :new
    end
  end

  private

  def report_params
    params.require(:abuse_report).permit(:user_id, :message)
  end
end