logo

pleroma

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

conversation_operation.ex (2165B)


  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.ConversationOperation do
  5. alias OpenApiSpex.Operation
  6. alias OpenApiSpex.Schema
  7. alias Pleroma.Web.ApiSpec.Schemas.Conversation
  8. alias Pleroma.Web.ApiSpec.Schemas.FlakeID
  9. import Pleroma.Web.ApiSpec.Helpers
  10. def open_api_operation(action) do
  11. operation = String.to_existing_atom("#{action}_operation")
  12. apply(__MODULE__, operation, [])
  13. end
  14. def index_operation do
  15. %Operation{
  16. tags: ["Conversations"],
  17. summary: "List of conversations",
  18. security: [%{"oAuth" => ["read:statuses"]}],
  19. operationId: "ConversationController.index",
  20. parameters: [
  21. Operation.parameter(
  22. :recipients,
  23. :query,
  24. %Schema{type: :array, items: FlakeID},
  25. "Only return conversations with the given recipients (a list of user ids)"
  26. )
  27. | pagination_params()
  28. ],
  29. responses: %{
  30. 200 =>
  31. Operation.response("Array of Conversation", "application/json", %Schema{
  32. type: :array,
  33. items: Conversation,
  34. example: [Conversation.schema().example]
  35. })
  36. }
  37. }
  38. end
  39. def mark_as_read_operation do
  40. %Operation{
  41. tags: ["Conversations"],
  42. summary: "Mark conversation as read",
  43. operationId: "ConversationController.mark_as_read",
  44. parameters: [id_param()],
  45. security: [%{"oAuth" => ["write:conversations"]}],
  46. responses: %{
  47. 200 => Operation.response("Conversation", "application/json", Conversation)
  48. }
  49. }
  50. end
  51. def delete_operation do
  52. %Operation{
  53. tags: ["Conversations"],
  54. summary: "Remove conversation",
  55. operationId: "ConversationController.delete",
  56. parameters: [id_param()],
  57. security: [%{"oAuth" => ["write:conversations"]}],
  58. responses: %{
  59. 200 => empty_object_response()
  60. }
  61. }
  62. end
  63. def id_param do
  64. Operation.parameter(:id, :path, :string, "Conversation ID",
  65. example: "123",
  66. required: true
  67. )
  68. end
  69. end