logo

pleroma

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

chat_operation.ex (2440B)


  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.Admin.ChatOperation do
  5. alias OpenApiSpex.Operation
  6. alias Pleroma.Web.ApiSpec.Schemas.Chat
  7. alias Pleroma.Web.ApiSpec.Schemas.ChatMessage
  8. import Pleroma.Web.ApiSpec.Helpers
  9. def open_api_operation(action) do
  10. operation = String.to_existing_atom("#{action}_operation")
  11. apply(__MODULE__, operation, [])
  12. end
  13. def delete_message_operation do
  14. %Operation{
  15. tags: ["Chat administration"],
  16. summary: "Delete an individual chat message",
  17. operationId: "AdminAPI.ChatController.delete_message",
  18. parameters: [
  19. Operation.parameter(:id, :path, :string, "The ID of the Chat"),
  20. Operation.parameter(:message_id, :path, :string, "The ID of the message")
  21. ],
  22. responses: %{
  23. 200 =>
  24. Operation.response(
  25. "The deleted ChatMessage",
  26. "application/json",
  27. ChatMessage
  28. )
  29. },
  30. security: [
  31. %{
  32. "oAuth" => ["admin:write:chats"]
  33. }
  34. ]
  35. }
  36. end
  37. def messages_operation do
  38. %Operation{
  39. tags: ["Chat administration"],
  40. summary: "Get chat's messages",
  41. operationId: "AdminAPI.ChatController.messages",
  42. parameters:
  43. [Operation.parameter(:id, :path, :string, "The ID of the Chat")] ++
  44. pagination_params(),
  45. responses: %{
  46. 200 =>
  47. Operation.response(
  48. "The messages in the chat",
  49. "application/json",
  50. Pleroma.Web.ApiSpec.ChatOperation.chat_messages_response()
  51. )
  52. },
  53. security: [
  54. %{
  55. "oAuth" => ["admin:read:chats"]
  56. }
  57. ]
  58. }
  59. end
  60. def show_operation do
  61. %Operation{
  62. tags: ["Chat administration"],
  63. summary: "Create a chat",
  64. operationId: "AdminAPI.ChatController.show",
  65. parameters: [
  66. Operation.parameter(
  67. :id,
  68. :path,
  69. :string,
  70. "The id of the chat",
  71. required: true,
  72. example: "1234"
  73. )
  74. ],
  75. responses: %{
  76. 200 =>
  77. Operation.response(
  78. "The existing chat",
  79. "application/json",
  80. Chat
  81. )
  82. },
  83. security: [
  84. %{
  85. "oAuth" => ["admin:read"]
  86. }
  87. ]
  88. }
  89. end
  90. end