]> cat aescling's git repositories - mastodon.git/blob - app/controllers/api/v1/reports_controller.rb
Adding POST /api/v1/reports API, and a UI for submitting reports
[mastodon.git] / app / controllers / api / v1 / reports_controller.rb
1 # frozen_string_literal: true
2
3 class Api::V1::ReportsController < ApiController
4 before_action -> { doorkeeper_authorize! :read }, except: [:create]
5 before_action -> { doorkeeper_authorize! :write }, only: [:create]
6 before_action :require_user!
7
8 respond_to :json
9
10 def index
11 @reports = Report.where(account: current_account)
12 end
13
14 def create
15 status_ids = params[:status_ids].is_a?(Enumerable) ? params[:status_ids] : [params[:status_ids]]
16
17 @report = Report.create!(account: current_account,
18 target_account: Account.find(params[:account_id]),
19 status_ids: Status.find(status_ids).pluck(:id),
20 comment: params[:comment])
21
22 render :show
23 end
24 end
This page took 0.079083 seconds and 4 git commands to generate.