logo

pleroma

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

follow_request_operation.ex (1928B)


  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.FollowRequestOperation do
  5. alias OpenApiSpex.Operation
  6. alias OpenApiSpex.Schema
  7. alias Pleroma.Web.ApiSpec.Schemas.Account
  8. alias Pleroma.Web.ApiSpec.Schemas.AccountRelationship
  9. def open_api_operation(action) do
  10. operation = String.to_existing_atom("#{action}_operation")
  11. apply(__MODULE__, operation, [])
  12. end
  13. def index_operation do
  14. %Operation{
  15. tags: ["Follow requests"],
  16. summary: "Retrieve follow requests",
  17. security: [%{"oAuth" => ["read:follows", "follow"]}],
  18. operationId: "FollowRequestController.index",
  19. responses: %{
  20. 200 =>
  21. Operation.response("Array of Account", "application/json", %Schema{
  22. type: :array,
  23. items: Account,
  24. example: [Account.schema().example]
  25. })
  26. }
  27. }
  28. end
  29. def authorize_operation do
  30. %Operation{
  31. tags: ["Follow requests"],
  32. summary: "Accept follow request",
  33. operationId: "FollowRequestController.authorize",
  34. parameters: [id_param()],
  35. security: [%{"oAuth" => ["follow", "write:follows"]}],
  36. responses: %{
  37. 200 => Operation.response("Relationship", "application/json", AccountRelationship)
  38. }
  39. }
  40. end
  41. def reject_operation do
  42. %Operation{
  43. tags: ["Follow requests"],
  44. summary: "Reject follow request",
  45. operationId: "FollowRequestController.reject",
  46. parameters: [id_param()],
  47. security: [%{"oAuth" => ["follow", "write:follows"]}],
  48. responses: %{
  49. 200 => Operation.response("Relationship", "application/json", AccountRelationship)
  50. }
  51. }
  52. end
  53. defp id_param do
  54. Operation.parameter(:id, :path, :string, "Conversation ID",
  55. example: "123",
  56. required: true
  57. )
  58. end
  59. end