2017-02-16 12:28:10 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-11 05:27:03 +10:00
|
|
|
module Admin
|
|
|
|
class ReportsController < BaseController
|
|
|
|
before_action :set_report, except: [:index]
|
|
|
|
|
|
|
|
def index
|
2017-11-12 06:23:33 +11:00
|
|
|
authorize :report, :index?
|
2017-04-14 19:10:28 +10:00
|
|
|
@reports = filtered_reports.page(params[:page])
|
2017-04-11 05:27:03 +10:00
|
|
|
end
|
|
|
|
|
2017-07-19 00:38:22 +10:00
|
|
|
def show
|
2017-11-12 06:23:33 +11:00
|
|
|
authorize @report, :show?
|
2018-04-20 10:28:48 +10: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-23 06:02:09 +11:00
|
|
|
@report_notes = (@report.notes.latest + @report.history + @report.target_account.targeted_account_warnings.latest.custom).sort_by(&:created_at)
|
2018-04-20 10:28:48 +10:00
|
|
|
@form = Form::StatusBatch.new
|
2017-07-19 00:38:22 +10:00
|
|
|
end
|
2017-04-11 05:27:03 +10: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 06:02:09 +11:00
|
|
|
def assign_to_self
|
2017-11-12 06:23:33 +11: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 06:02:09 +11:00
|
|
|
@report.update!(assigned_account_id: current_account.id)
|
|
|
|
log_action :assigned_to_self, @report
|
|
|
|
redirect_to admin_report_path(@report)
|
2017-04-11 05:27:03 +10: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 06:02:09 +11: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 05:27:03 +10: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 06:02:09 +11:00
|
|
|
def reopen
|
|
|
|
authorize @report, :update?
|
|
|
|
@report.unresolve!
|
|
|
|
log_action :reopen, @report
|
|
|
|
redirect_to admin_report_path(@report)
|
2017-04-11 05:27:03 +10: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 06:02:09 +11: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 19:10:28 +10: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 06:02:09 +11:00
|
|
|
private
|
|
|
|
|
2017-04-14 19:10:28 +10: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 06:02:09 +11:00
|
|
|
ReportFilter.new(filter_params).results.order(id: :desc).includes(:account, :target_account)
|
2017-04-14 19:10:28 +10:00
|
|
|
end
|
|
|
|
|
2017-04-19 03:36:18 +10:00
|
|
|
def filter_params
|
|
|
|
params.permit(
|
|
|
|
:account_id,
|
|
|
|
:resolved,
|
2019-12-01 05:53:58 +11:00
|
|
|
:target_account_id,
|
|
|
|
:by_target_domain
|
2017-04-19 03:36:18 +10:00
|
|
|
)
|
2017-04-14 19:10:28 +10:00
|
|
|
end
|
2017-04-11 05:27:03 +10:00
|
|
|
|
|
|
|
def set_report
|
|
|
|
@report = Report.find(params[:id])
|
|
|
|
end
|
2017-02-17 10:42:52 +11:00
|
|
|
end
|
2017-02-16 12:28:10 +11:00
|
|
|
end
|