2020-04-28 06:50:37 -06:00
|
|
|
# Pleroma: A lightweight social networking server
|
2021-01-12 23:49:20 -07:00
|
|
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
2020-04-28 06:50:37 -06:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.ApiSpec.ReportOperation do
|
|
|
|
alias OpenApiSpex.Operation
|
|
|
|
alias OpenApiSpex.Schema
|
|
|
|
alias Pleroma.Web.ApiSpec.Helpers
|
|
|
|
alias Pleroma.Web.ApiSpec.Schemas.ApiError
|
2020-05-18 10:58:59 -06:00
|
|
|
alias Pleroma.Web.ApiSpec.Schemas.BooleanLike
|
2020-04-28 06:50:37 -06:00
|
|
|
|
|
|
|
def open_api_operation(action) do
|
|
|
|
operation = String.to_existing_atom("#{action}_operation")
|
|
|
|
apply(__MODULE__, operation, [])
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_operation do
|
|
|
|
%Operation{
|
|
|
|
tags: ["reports"],
|
|
|
|
summary: "File a report",
|
|
|
|
description: "Report problematic users to your moderators",
|
|
|
|
operationId: "ReportController.create",
|
|
|
|
security: [%{"oAuth" => ["follow", "write:reports"]}],
|
|
|
|
requestBody: Helpers.request_body("Parameters", create_request(), required: true),
|
|
|
|
responses: %{
|
|
|
|
200 => Operation.response("Report", "application/json", create_response()),
|
|
|
|
400 => Operation.response("Report", "application/json", ApiError)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
defp create_request do
|
|
|
|
%Schema{
|
|
|
|
title: "ReportCreateRequest",
|
|
|
|
description: "POST body for creating a report",
|
|
|
|
type: :object,
|
|
|
|
properties: %{
|
|
|
|
account_id: %Schema{type: :string, description: "ID of the account to report"},
|
|
|
|
status_ids: %Schema{
|
|
|
|
type: :array,
|
2020-05-15 04:55:41 -06:00
|
|
|
nullable: true,
|
2020-04-28 06:50:37 -06:00
|
|
|
items: %Schema{type: :string},
|
|
|
|
description: "Array of Statuses to attach to the report, for context"
|
|
|
|
},
|
|
|
|
comment: %Schema{
|
|
|
|
type: :string,
|
2020-05-15 04:55:41 -06:00
|
|
|
nullable: true,
|
2020-04-28 06:50:37 -06:00
|
|
|
description: "Reason for the report"
|
|
|
|
},
|
|
|
|
forward: %Schema{
|
2020-05-18 10:58:59 -06:00
|
|
|
allOf: [BooleanLike],
|
2020-05-15 04:55:41 -06:00
|
|
|
nullable: true,
|
2020-04-28 06:50:37 -06:00
|
|
|
default: false,
|
|
|
|
description:
|
|
|
|
"If the account is remote, should the report be forwarded to the remote admin?"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
required: [:account_id],
|
|
|
|
example: %{
|
|
|
|
"account_id" => "123",
|
|
|
|
"status_ids" => ["1337"],
|
|
|
|
"comment" => "bad status!",
|
|
|
|
"forward" => "false"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
defp create_response do
|
|
|
|
%Schema{
|
|
|
|
title: "ReportResponse",
|
|
|
|
type: :object,
|
|
|
|
properties: %{
|
|
|
|
id: %Schema{type: :string, description: "Report ID"},
|
|
|
|
action_taken: %Schema{type: :boolean, description: "Is action taken?"}
|
|
|
|
},
|
|
|
|
example: %{
|
|
|
|
"id" => "123",
|
|
|
|
"action_taken" => false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|