logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

pleroma_report_operation.ex (2855B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.ApiSpec.PleromaReportOperation do
  5. alias OpenApiSpex.Operation
  6. alias OpenApiSpex.Schema
  7. alias Pleroma.Web.ApiSpec.Admin.ReportOperation
  8. alias Pleroma.Web.ApiSpec.Schemas.Account
  9. alias Pleroma.Web.ApiSpec.Schemas.ApiError
  10. alias Pleroma.Web.ApiSpec.Schemas.FlakeID
  11. alias Pleroma.Web.ApiSpec.Schemas.Status
  12. def open_api_operation(action) do
  13. operation = String.to_existing_atom("#{action}_operation")
  14. apply(__MODULE__, operation, [])
  15. end
  16. def index_operation do
  17. %Operation{
  18. tags: ["Reports"],
  19. summary: "Get a list of your own reports",
  20. operationId: "PleromaAPI.ReportController.index",
  21. security: [%{"oAuth" => ["read:reports"]}],
  22. parameters: [
  23. Operation.parameter(
  24. :state,
  25. :query,
  26. ReportOperation.report_state(),
  27. "Filter by report state"
  28. ),
  29. Operation.parameter(
  30. :limit,
  31. :query,
  32. %Schema{type: :integer},
  33. "The number of records to retrieve"
  34. ),
  35. Operation.parameter(
  36. :page,
  37. :query,
  38. %Schema{type: :integer, default: 1},
  39. "Page number"
  40. ),
  41. Operation.parameter(
  42. :page_size,
  43. :query,
  44. %Schema{type: :integer, default: 50},
  45. "Number number of log entries per page"
  46. )
  47. ],
  48. responses: %{
  49. 200 =>
  50. Operation.response("Response", "application/json", %Schema{
  51. type: :object,
  52. properties: %{
  53. total: %Schema{type: :integer},
  54. reports: %Schema{
  55. type: :array,
  56. items: report()
  57. }
  58. }
  59. }),
  60. 404 => Operation.response("Not Found", "application/json", ApiError)
  61. }
  62. }
  63. end
  64. def show_operation do
  65. %Operation{
  66. tags: ["Reports"],
  67. summary: "Get an individual report",
  68. operationId: "PleromaAPI.ReportController.show",
  69. parameters: [ReportOperation.id_param()],
  70. security: [%{"oAuth" => ["read:reports"]}],
  71. responses: %{
  72. 200 => Operation.response("Report", "application/json", report()),
  73. 404 => Operation.response("Not Found", "application/json", ApiError)
  74. }
  75. }
  76. end
  77. # Copied from ReportOperation.report with removing notes
  78. defp report do
  79. %Schema{
  80. type: :object,
  81. properties: %{
  82. id: FlakeID,
  83. state: ReportOperation.report_state(),
  84. account: Account,
  85. actor: Account,
  86. content: %Schema{type: :string},
  87. created_at: %Schema{type: :string, format: :"date-time"},
  88. statuses: %Schema{type: :array, items: Status}
  89. }
  90. }
  91. end
  92. end