2017-02-16 02:28:10 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-10 21:27:03 +02:00
|
|
|
module Admin
|
|
|
|
class ReportsController < BaseController
|
|
|
|
before_action :set_report, except: [:index]
|
|
|
|
|
|
|
|
def index
|
2017-11-11 20:23:33 +01:00
|
|
|
authorize :report, :index?
|
2017-04-14 11:10:28 +02:00
|
|
|
@reports = filtered_reports.page(params[:page])
|
2017-04-10 21:27:03 +02:00
|
|
|
end
|
|
|
|
|
2017-07-18 16:38:22 +02:00
|
|
|
def show
|
2017-11-11 20:23:33 +01:00
|
|
|
authorize @report, :show?
|
2018-04-20 02:28:48 +02:00
|
|
|
|
|
|
|
@report_note = @report.notes.new
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-22 20:02:09 +01:00
|
|
|
@report_notes = (@report.notes.latest + @report.history + @report.target_account.targeted_account_warnings.latest.custom).sort_by(&:created_at)
|
2018-04-20 02:28:48 +02:00
|
|
|
@form = Form::StatusBatch.new
|
2017-07-18 16:38:22 +02:00
|
|
|
end
|
2017-04-10 21:27:03 +02:00
|
|
|
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-22 20:02:09 +01:00
|
|
|
def assign_to_self
|
2017-11-11 20:23:33 +01:00
|
|
|
authorize @report, :update?
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-22 20:02:09 +01:00
|
|
|
@report.update!(assigned_account_id: current_account.id)
|
|
|
|
log_action :assigned_to_self, @report
|
|
|
|
redirect_to admin_report_path(@report)
|
2017-04-10 21:27:03 +02:00
|
|
|
end
|
|
|
|
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-22 20:02:09 +01:00
|
|
|
def unassign
|
|
|
|
authorize @report, :update?
|
|
|
|
@report.update!(assigned_account_id: nil)
|
|
|
|
log_action :unassigned, @report
|
|
|
|
redirect_to admin_report_path(@report)
|
2017-04-10 21:27:03 +02:00
|
|
|
end
|
|
|
|
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-22 20:02:09 +01:00
|
|
|
def reopen
|
|
|
|
authorize @report, :update?
|
|
|
|
@report.unresolve!
|
|
|
|
log_action :reopen, @report
|
|
|
|
redirect_to admin_report_path(@report)
|
2017-04-10 21:27:03 +02:00
|
|
|
end
|
|
|
|
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-22 20:02:09 +01:00
|
|
|
def resolve
|
|
|
|
authorize @report, :update?
|
|
|
|
@report.resolve!(current_account)
|
|
|
|
log_action :resolve, @report
|
|
|
|
redirect_to admin_reports_path, notice: I18n.t('admin.reports.resolved_msg')
|
2017-04-14 11:10:28 +02:00
|
|
|
end
|
|
|
|
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-22 20:02:09 +01:00
|
|
|
private
|
|
|
|
|
2017-04-14 11:10:28 +02:00
|
|
|
def filtered_reports
|
Add moderation warnings (#9519)
* Add moderation warnings
Replace individual routes for disabling, silencing, and suspending
a user, as well as the report update route, with a unified account
action controller that allows you to select an action (none,
disable, silence, suspend) as well as whether it should generate an
e-mail notification with optional custom text. That notification,
with the optional custom text, is saved as a warning.
Additionally, there are warning presets you can configure to save
time when performing the above.
* Use Account#local_username_and_domain
2018-12-22 20:02:09 +01:00
|
|
|
ReportFilter.new(filter_params).results.order(id: :desc).includes(:account, :target_account)
|
2017-04-14 11:10:28 +02:00
|
|
|
end
|
|
|
|
|
2017-04-18 19:36:18 +02:00
|
|
|
def filter_params
|
|
|
|
params.permit(
|
|
|
|
:account_id,
|
|
|
|
:resolved,
|
2019-11-30 19:53:58 +01:00
|
|
|
:target_account_id,
|
|
|
|
:by_target_domain
|
2017-04-18 19:36:18 +02:00
|
|
|
)
|
2017-04-14 11:10:28 +02:00
|
|
|
end
|
2017-04-10 21:27:03 +02:00
|
|
|
|
|
|
|
def set_report
|
|
|
|
@report = Report.find(params[:id])
|
|
|
|
end
|
2017-02-17 00:42:52 +01:00
|
|
|
end
|
2017-02-16 02:28:10 +01:00
|
|
|
end
|