logo

pleroma

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

pleroma_notification_operation.ex (1446B)


  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.PleromaNotificationOperation do
  5. alias OpenApiSpex.Operation
  6. alias OpenApiSpex.Schema
  7. alias Pleroma.Web.ApiSpec.Schemas.ApiError
  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 mark_as_read_operation do
  14. %Operation{
  15. tags: ["Notifications"],
  16. summary: "Mark notifications as read",
  17. description: "Query parameters are mutually exclusive.",
  18. requestBody:
  19. request_body("Parameters", %Schema{
  20. type: :object,
  21. properties: %{
  22. id: %Schema{type: :integer, description: "A single notification ID to read"},
  23. max_id: %Schema{type: :integer, description: "Read all notifications up to this ID"}
  24. }
  25. }),
  26. security: [%{"oAuth" => ["write:notifications"]}],
  27. operationId: "PleromaAPI.NotificationController.mark_as_read",
  28. responses: %{
  29. 200 =>
  30. Operation.response(
  31. "A Notification or array of Notifications",
  32. "application/json",
  33. %Schema{type: :string}
  34. ),
  35. 400 => Operation.response("Bad Request", "application/json", ApiError)
  36. }
  37. }
  38. end
  39. end