Retrospring/app/controllers/moderation_controller.rb

33 lines
853 B
Ruby
Raw Normal View History

2014-12-25 14:00:33 -08:00
class ModerationController < ApplicationController
2020-04-18 16:45:50 -07:00
before_action :authenticate_user!
2014-12-28 16:25:48 -08:00
2014-12-25 14:00:33 -08:00
def index
2014-12-28 16:25:48 -08:00
@type = params[:type]
@reports = list_reports(type: @type, last_id: params[:last_id])
@reports_last_id = @reports.map(&:id).min
@more_data_available = !list_reports(type: @type, last_id: @reports_last_id, size: 1).count.zero?
respond_to do |format|
format.html
format.js { render layout: false }
end
2014-12-25 14:00:33 -08:00
end
2015-07-23 10:38:42 -07:00
2022-06-23 14:35:33 -07:00
def toggle_unmask
session[:moderation_view] = !session[:moderation_view]
redirect_back fallback_location: root_path
end
private
def list_reports(type:, last_id:, size: nil)
cursor_params = { last_id: last_id, size: size }.compact
if type == 'all'
Report.cursored_reports(**cursor_params)
else
Report.cursored_reports_of_type(type, **cursor_params)
end
end
2014-12-25 14:00:33 -08:00
end