logo

pleroma

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

pleroma_notification_operation.ex (1672B)


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