logo

pleroma

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

pleroma_conversation_operation.ex (3322B)


  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.PleromaConversationOperation do
  5. alias OpenApiSpex.Operation
  6. alias OpenApiSpex.Schema
  7. alias Pleroma.Web.ApiSpec.Schemas.Conversation
  8. alias Pleroma.Web.ApiSpec.Schemas.FlakeID
  9. alias Pleroma.Web.ApiSpec.StatusOperation
  10. import Pleroma.Web.ApiSpec.Helpers
  11. def open_api_operation(action) do
  12. operation = String.to_existing_atom("#{action}_operation")
  13. apply(__MODULE__, operation, [])
  14. end
  15. def show_operation do
  16. %Operation{
  17. tags: ["Conversations"],
  18. summary: "Conversation",
  19. parameters: [
  20. Operation.parameter(:id, :path, :string, "Conversation ID",
  21. example: "123",
  22. required: true
  23. )
  24. ],
  25. security: [%{"oAuth" => ["read:statuses"]}],
  26. operationId: "PleromaAPI.ConversationController.show",
  27. responses: %{
  28. 200 => Operation.response("Conversation", "application/json", Conversation)
  29. }
  30. }
  31. end
  32. def statuses_operation do
  33. %Operation{
  34. tags: ["Conversations"],
  35. summary: "Timeline for conversation",
  36. parameters: [
  37. Operation.parameter(:id, :path, :string, "Conversation ID",
  38. example: "123",
  39. required: true
  40. )
  41. | pagination_params()
  42. ],
  43. security: [%{"oAuth" => ["read:statuses"]}],
  44. operationId: "PleromaAPI.ConversationController.statuses",
  45. responses: %{
  46. 200 =>
  47. Operation.response(
  48. "Array of Statuses",
  49. "application/json",
  50. StatusOperation.array_of_statuses()
  51. )
  52. }
  53. }
  54. end
  55. def update_operation do
  56. %Operation{
  57. tags: ["Conversations"],
  58. summary: "Update conversation",
  59. description: "Change set of recipients for the conversation.",
  60. parameters: [
  61. Operation.parameter(:id, :path, :string, "Conversation ID",
  62. example: "123",
  63. required: true
  64. ),
  65. Operation.parameter(
  66. :recipients,
  67. :query,
  68. %Schema{type: :array, items: FlakeID},
  69. "A list of ids of users that should receive posts to this conversation. This will replace the current list of recipients, so submit the full list. The owner of owner of the conversation will always be part of the set of recipients, though.",
  70. required: true
  71. )
  72. ],
  73. security: [%{"oAuth" => ["write:conversations"]}],
  74. operationId: "PleromaAPI.ConversationController.update",
  75. responses: %{
  76. 200 => Operation.response("Conversation", "application/json", Conversation)
  77. }
  78. }
  79. end
  80. def mark_as_read_operation do
  81. %Operation{
  82. tags: ["Conversations"],
  83. summary: "Marks all conversations as read",
  84. security: [%{"oAuth" => ["write:conversations"]}],
  85. operationId: "PleromaAPI.ConversationController.mark_as_read",
  86. responses: %{
  87. 200 =>
  88. Operation.response(
  89. "Array of Conversations that were marked as read",
  90. "application/json",
  91. %Schema{
  92. type: :array,
  93. items: Conversation,
  94. example: [Conversation.schema().example]
  95. }
  96. )
  97. }
  98. }
  99. end
  100. end