mirror of https://framagit.org/tykayn/mastodon
parent
6fac300ea4
commit
5e8c2baa20
@ -0,0 +1,46 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::Admin::AccountsController < Api::BaseController
|
||||
before_action -> { doorkeeper_authorize! :'admin:read', :'admin:read:accounts' }
|
||||
before_action :require_staff!
|
||||
before_action :set_accounts, only: :index
|
||||
before_action :set_account, only: :show
|
||||
|
||||
def index
|
||||
render json: @accounts, each_serializer: REST::Admin::AccountSerializer
|
||||
end
|
||||
|
||||
def show
|
||||
render json: @account, serializer: REST::Admin::AccountSerializer
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_accounts
|
||||
@accounts = filtered_accounts
|
||||
end
|
||||
|
||||
def set_account
|
||||
@account = Account.find(params[:id])
|
||||
end
|
||||
|
||||
def filtered_accounts
|
||||
AccountFilter.new(filter_params).results
|
||||
end
|
||||
|
||||
def filter_params
|
||||
params.permit(
|
||||
:local,
|
||||
:remote,
|
||||
:by_domain,
|
||||
:active,
|
||||
:silenced,
|
||||
:suspended,
|
||||
:username,
|
||||
:display_name,
|
||||
:email,
|
||||
:ip,
|
||||
:staff
|
||||
)
|
||||
end
|
||||
end
|
@ -0,0 +1,38 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::Admin::ReportsController < Api::BaseController
|
||||
before_action -> { doorkeeper_authorize! :'admin:read', :'admin:read:reports' }
|
||||
before_action :require_staff!
|
||||
before_action :set_reports, only: :index
|
||||
before_action :set_report, only: :show
|
||||
|
||||
def index
|
||||
render json: @reports, each_serializer: REST::Admin::ReportSerializer
|
||||
end
|
||||
|
||||
def show
|
||||
render json: @report, serializer: REST::Admin::ReportSerializer
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_reports
|
||||
@reports = filtered_reports.order(id: :desc)
|
||||
end
|
||||
|
||||
def set_report
|
||||
@report = Report.find(params[:id])
|
||||
end
|
||||
|
||||
def filtered_reports
|
||||
ReportFilter.new(filter_params).results
|
||||
end
|
||||
|
||||
def filter_params
|
||||
params.permit(
|
||||
:resolved,
|
||||
:account_id,
|
||||
:target_account_id
|
||||
)
|
||||
end
|
||||
end
|
@ -0,0 +1,35 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::Admin::AccountSerializer < ActiveModel::Serializer
|
||||
attributes :id, :username, :domain, :url, :created_at,
|
||||
:email, :ip, :role, :confirmed, :suspended,
|
||||
:silenced, :disabled
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
def url
|
||||
ActivityPub::TagManager.instance.url_for(object)
|
||||
end
|
||||
|
||||
def email
|
||||
object.user_email
|
||||
end
|
||||
|
||||
def ip
|
||||
object.user_current_sign_in_ip.to_s.presence
|
||||
end
|
||||
|
||||
def role
|
||||
object.user_role
|
||||
end
|
||||
|
||||
def confirmed
|
||||
object.user_confirmed?
|
||||
end
|
||||
|
||||
def disabled
|
||||
object.user_disabled?
|
||||
end
|
||||
end
|
@ -0,0 +1,29 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::Admin::ReportSerializer < ActiveModel::Serializer
|
||||
attributes :id, :action_taken, :comment, :created_at, :updated_at,
|
||||
:account_id, :target_account_id, :assigned_account_id,
|
||||
:action_taken_by_account_id
|
||||
|
||||
has_many :statuses, serializer: REST::StatusSerializer
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
end
|
||||
|
||||
def account_id
|
||||
object.account_id.to_s.presence
|
||||
end
|
||||
|
||||
def target_account_id
|
||||
object.target_account_id.to_s.presence
|
||||
end
|
||||
|
||||
def assigned_account_id
|
||||
object.assigned_account_id.to_s.presence
|
||||
end
|
||||
|
||||
def action_taken_by_account_id
|
||||
object.action_taken_by_account_id.to_s.presence
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue