1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.MastodonAPI.ReportController do
6 alias Pleroma.Plugs.OAuthScopesPlug
8 use Pleroma.Web, :controller
10 action_fallback(Pleroma.Web.MastodonAPI.FallbackController)
12 plug(Pleroma.Web.ApiSpec.CastAndValidate)
13 plug(OAuthScopesPlug, %{scopes: ["write:reports"]} when action == :create)
15 defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.ReportOperation
17 @doc "POST /api/v1/reports"
18 def create(%{assigns: %{user: user}, body_params: params} = conn, _) do
19 with {:ok, activity} <- Pleroma.Web.CommonAPI.report(user, params) do
20 render(conn, "show.json", activity: activity)