2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
class AbuseReportsController < ApplicationController
|
2017-09-10 17:25:29 +05:30
|
|
|
before_action :set_user, only: [:new]
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
feature_category :insider_threat
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
def new
|
|
|
|
@abuse_report = AbuseReport.new
|
2017-09-10 17:25:29 +05:30
|
|
|
@abuse_report.user_id = @user.id
|
2016-01-19 16:12:03 +05:30
|
|
|
@ref_url = params.fetch(:ref_url, '')
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@abuse_report = AbuseReport.new(report_params)
|
|
|
|
@abuse_report.reporter = current_user
|
|
|
|
|
|
|
|
if @abuse_report.save
|
2016-01-14 18:37:52 +05:30
|
|
|
@abuse_report.notify
|
2015-10-24 18:46:33 +05:30
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
message = _("Thank you for your report. A GitLab administrator will look into it shortly.")
|
2021-09-04 01:27:46 +05:30
|
|
|
redirect_to root_path, notice: message
|
2022-04-04 11:22:00 +05:30
|
|
|
elsif report_params[:user_id].present?
|
2015-09-11 14:41:01 +05:30
|
|
|
render :new
|
2022-04-04 11:22:00 +05:30
|
|
|
else
|
|
|
|
redirect_to root_path, alert: _("Cannot create the abuse report. The reported user was invalid. Please try again or contact support.")
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def report_params
|
2022-10-11 01:57:18 +05:30
|
|
|
params.require(:abuse_report).permit(:message, :user_id)
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2017-09-10 17:25:29 +05:30
|
|
|
def set_user
|
|
|
|
@user = User.find_by(id: params[:user_id])
|
|
|
|
|
|
|
|
if @user.nil?
|
2019-07-31 22:56:46 +05:30
|
|
|
redirect_to root_path, alert: _("Cannot create the abuse report. The user has been deleted.")
|
2017-09-10 17:25:29 +05:30
|
|
|
elsif @user.blocked?
|
2019-07-31 22:56:46 +05:30
|
|
|
redirect_to @user, alert: _("Cannot create the abuse report. This user has been blocked.")
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2015-09-11 14:41:01 +05:30
|
|
|
end
|