logo

pleroma

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

scheduled_activity_operation.ex (2982B)


  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.ScheduledActivityOperation do
  5. alias OpenApiSpex.Operation
  6. alias OpenApiSpex.Schema
  7. alias Pleroma.Web.ApiSpec.Schemas.ApiError
  8. alias Pleroma.Web.ApiSpec.Schemas.FlakeID
  9. alias Pleroma.Web.ApiSpec.Schemas.ScheduledStatus
  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 index_operation do
  16. %Operation{
  17. tags: ["Scheduled statuses"],
  18. summary: "View scheduled statuses",
  19. security: [%{"oAuth" => ["read:statuses"]}],
  20. parameters: pagination_params(),
  21. operationId: "ScheduledActivity.index",
  22. responses: %{
  23. 200 =>
  24. Operation.response("Array of ScheduledStatus", "application/json", %Schema{
  25. type: :array,
  26. items: ScheduledStatus
  27. })
  28. }
  29. }
  30. end
  31. def show_operation do
  32. %Operation{
  33. tags: ["Scheduled statuses"],
  34. summary: "View a single scheduled status",
  35. security: [%{"oAuth" => ["read:statuses"]}],
  36. parameters: [id_param()],
  37. operationId: "ScheduledActivity.show",
  38. responses: %{
  39. 200 => Operation.response("Scheduled Status", "application/json", ScheduledStatus),
  40. 404 => Operation.response("Error", "application/json", ApiError)
  41. }
  42. }
  43. end
  44. def update_operation do
  45. %Operation{
  46. tags: ["Scheduled statuses"],
  47. summary: "Schedule a status",
  48. operationId: "ScheduledActivity.update",
  49. security: [%{"oAuth" => ["write:statuses"]}],
  50. parameters: [id_param()],
  51. requestBody:
  52. request_body("Parameters", %Schema{
  53. type: :object,
  54. properties: %{
  55. scheduled_at: %Schema{
  56. type: :string,
  57. format: :"date-time",
  58. description:
  59. "ISO 8601 Datetime at which the status will be published. Must be at least 5 minutes into the future."
  60. }
  61. }
  62. }),
  63. responses: %{
  64. 200 => Operation.response("Scheduled Status", "application/json", ScheduledStatus),
  65. 404 => Operation.response("Error", "application/json", ApiError)
  66. }
  67. }
  68. end
  69. def delete_operation do
  70. %Operation{
  71. tags: ["Scheduled statuses"],
  72. summary: "Cancel a scheduled status",
  73. security: [%{"oAuth" => ["write:statuses"]}],
  74. parameters: [id_param()],
  75. operationId: "ScheduledActivity.delete",
  76. responses: %{
  77. 200 => Operation.response("Empty object", "application/json", %Schema{type: :object}),
  78. 404 => Operation.response("Error", "application/json", ApiError)
  79. }
  80. }
  81. end
  82. defp id_param do
  83. Operation.parameter(:id, :path, FlakeID.schema(), "Poll ID",
  84. example: "123",
  85. required: true
  86. )
  87. end
  88. end