2019-09-30 12:04:03 +02:00
|
|
|
# Pleroma: A lightweight social networking server
|
2020-03-03 23:44:49 +01:00
|
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
2019-09-30 12:04:03 +02:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.MastodonAPI.ReportController do
|
2019-10-02 19:42:40 +02:00
|
|
|
alias Pleroma.Plugs.OAuthScopesPlug
|
|
|
|
|
2019-09-30 12:04:03 +02:00
|
|
|
use Pleroma.Web, :controller
|
|
|
|
|
|
|
|
action_fallback(Pleroma.Web.MastodonAPI.FallbackController)
|
|
|
|
|
2020-04-28 14:50:37 +02:00
|
|
|
plug(OpenApiSpex.Plug.CastAndValidate, render_error: Pleroma.Web.ApiSpec.RenderError)
|
2019-10-02 19:42:40 +02:00
|
|
|
plug(OAuthScopesPlug, %{scopes: ["write:reports"]} when action == :create)
|
2019-10-06 16:12:17 +02:00
|
|
|
|
2020-04-28 14:50:37 +02:00
|
|
|
defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.ReportOperation
|
|
|
|
|
2019-09-30 12:04:03 +02:00
|
|
|
@doc "POST /api/v1/reports"
|
2020-04-28 14:50:37 +02:00
|
|
|
def create(%{assigns: %{user: user}, body_params: params} = conn, _) do
|
2019-09-30 12:04:03 +02:00
|
|
|
with {:ok, activity} <- Pleroma.Web.CommonAPI.report(user, params) do
|
|
|
|
render(conn, "show.json", activity: activity)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|