2017-02-16 10:28:10 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-11 04:27:03 +09:00
|
|
|
module Admin
|
|
|
|
class ReportsController < BaseController
|
|
|
|
before_action :set_report, except: [:index]
|
|
|
|
|
|
|
|
def index
|
2017-11-12 04:23:33 +09:00
|
|
|
authorize :report, :index?
|
2017-04-14 18:10:28 +09:00
|
|
|
@reports = filtered_reports.page(params[:page])
|
2017-04-11 04:27:03 +09:00
|
|
|
end
|
|
|
|
|
2017-07-18 23:38:22 +09:00
|
|
|
def show
|
2017-11-12 04:23:33 +09:00
|
|
|
authorize @report, :show?
|
2018-04-20 09:28:48 +09:00
|
|
|
|
|
|
|
@report_note = @report.notes.new
|
2022-01-17 17:41:33 +09:00
|
|
|
@report_notes = @report.notes.includes(:account).order(id: :desc)
|
|
|
|
@action_logs = @report.history.includes(:target)
|
|
|
|
@form = Admin::StatusBatchAction.new
|
|
|
|
@statuses = @report.statuses.with_includes
|
2017-07-18 23:38:22 +09:00
|
|
|
end
|
2017-04-11 04:27:03 +09: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-23 04:02:09 +09:00
|
|
|
def assign_to_self
|
2017-11-12 04:23:33 +09: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-23 04:02:09 +09:00
|
|
|
@report.update!(assigned_account_id: current_account.id)
|
|
|
|
log_action :assigned_to_self, @report
|
|
|
|
redirect_to admin_report_path(@report)
|
2017-04-11 04:27:03 +09: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-23 04:02:09 +09:00
|
|
|
def unassign
|
|
|
|
authorize @report, :update?
|
|
|
|
@report.update!(assigned_account_id: nil)
|
|
|
|
log_action :unassigned, @report
|
|
|
|
redirect_to admin_report_path(@report)
|
2017-04-11 04:27:03 +09: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-23 04:02:09 +09:00
|
|
|
def reopen
|
|
|
|
authorize @report, :update?
|
|
|
|
@report.unresolve!
|
|
|
|
log_action :reopen, @report
|
|
|
|
redirect_to admin_report_path(@report)
|
2017-04-11 04:27:03 +09: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-23 04:02:09 +09: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 18:10:28 +09: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-23 04:02:09 +09:00
|
|
|
private
|
|
|
|
|
2017-04-14 18:10:28 +09: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-23 04:02:09 +09:00
|
|
|
ReportFilter.new(filter_params).results.order(id: :desc).includes(:account, :target_account)
|
2017-04-14 18:10:28 +09:00
|
|
|
end
|
|
|
|
|
2017-04-19 02:36:18 +09:00
|
|
|
def filter_params
|
2020-01-20 23:55:03 +09:00
|
|
|
params.slice(*ReportFilter::KEYS).permit(*ReportFilter::KEYS)
|
2017-04-14 18:10:28 +09:00
|
|
|
end
|
2017-04-11 04:27:03 +09:00
|
|
|
|
|
|
|
def set_report
|
|
|
|
@report = Report.find(params[:id])
|
|
|
|
end
|
2017-02-17 08:42:52 +09:00
|
|
|
end
|
2017-02-16 10:28:10 +09:00
|
|
|
end
|