2015-08-06 08:03:27 -04:00
|
|
|
class AbuseReportsController < ApplicationController
|
2017-06-27 16:43:02 -04:00
|
|
|
before_action :set_user, only: [:new]
|
|
|
|
|
2015-08-06 08:03:27 -04:00
|
|
|
def new
|
|
|
|
@abuse_report = AbuseReport.new
|
2017-06-27 16:43:02 -04:00
|
|
|
@abuse_report.user_id = @user.id
|
2016-01-12 12:36:28 -05:00
|
|
|
@ref_url = params.fetch(:ref_url, '')
|
2015-08-06 08:03:27 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@abuse_report = AbuseReport.new(report_params)
|
|
|
|
@abuse_report.reporter = current_user
|
|
|
|
|
|
|
|
if @abuse_report.save
|
2016-01-04 18:59:42 -05:00
|
|
|
@abuse_report.notify
|
2015-10-18 05:58:45 -04:00
|
|
|
|
|
|
|
message = "Thank you for your report. A GitLab administrator will look into it shortly."
|
2016-01-04 18:46:43 -05:00
|
|
|
redirect_to @abuse_report.user, notice: message
|
2015-08-06 08:03:27 -04:00
|
|
|
else
|
|
|
|
render :new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def report_params
|
2016-01-04 18:46:43 -05:00
|
|
|
params.require(:abuse_report).permit(%i(
|
|
|
|
message
|
|
|
|
user_id
|
|
|
|
))
|
2015-08-06 08:03:27 -04:00
|
|
|
end
|
2017-06-27 16:43:02 -04:00
|
|
|
|
|
|
|
def set_user
|
|
|
|
@user = User.find_by(id: params[:user_id])
|
|
|
|
|
|
|
|
if @user.nil?
|
|
|
|
redirect_to root_path, alert: "Cannot create the abuse report. The user has been deleted."
|
|
|
|
elsif @user.blocked?
|
|
|
|
redirect_to @user, alert: "Cannot create the abuse report. This user has been blocked."
|
|
|
|
end
|
|
|
|
end
|
2015-08-06 08:03:27 -04:00
|
|
|
end
|