logo

pleroma

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

pleroma_account_operation.ex (4870B)


  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.PleromaAccountOperation do
  5. alias OpenApiSpex.Operation
  6. alias OpenApiSpex.Schema
  7. alias Pleroma.Web.ApiSpec.AccountOperation
  8. alias Pleroma.Web.ApiSpec.Schemas.AccountRelationship
  9. alias Pleroma.Web.ApiSpec.Schemas.ApiError
  10. alias Pleroma.Web.ApiSpec.Schemas.FlakeID
  11. alias Pleroma.Web.ApiSpec.StatusOperation
  12. import Pleroma.Web.ApiSpec.Helpers
  13. def open_api_operation(action) do
  14. operation = String.to_existing_atom("#{action}_operation")
  15. apply(__MODULE__, operation, [])
  16. end
  17. def confirmation_resend_operation do
  18. %Operation{
  19. tags: ["Account credentials"],
  20. summary: "Resend confirmation email",
  21. description: "Expects `email` or `nickname`.",
  22. operationId: "PleromaAPI.AccountController.confirmation_resend",
  23. parameters: [
  24. Operation.parameter(:email, :query, :string, "Email of that needs to be verified",
  25. example: "cofe@cofe.io"
  26. ),
  27. Operation.parameter(
  28. :nickname,
  29. :query,
  30. :string,
  31. "Nickname of user that needs to be verified",
  32. example: "cofefe"
  33. )
  34. ],
  35. responses: %{
  36. 204 => no_content_response()
  37. }
  38. }
  39. end
  40. def favourites_operation do
  41. %Operation{
  42. tags: ["Retrieve account information"],
  43. summary: "Favorites",
  44. description:
  45. "Only returns data if the user has opted into sharing it. See `hide_favorites` in [Update account credentials](#operation/AccountController.update_credentials).",
  46. operationId: "PleromaAPI.AccountController.favourites",
  47. parameters: [id_param() | pagination_params()],
  48. security: [%{"oAuth" => ["read:favourites"]}],
  49. responses: %{
  50. 200 =>
  51. Operation.response(
  52. "Array of Statuses",
  53. "application/json",
  54. StatusOperation.array_of_statuses()
  55. ),
  56. 403 => Operation.response("Forbidden", "application/json", ApiError),
  57. 404 => Operation.response("Not Found", "application/json", ApiError)
  58. }
  59. }
  60. end
  61. def endorsements_operation do
  62. %Operation{
  63. tags: ["Retrieve account information"],
  64. summary: "Endorsements",
  65. description: "Returns endorsed accounts",
  66. operationId: "PleromaAPI.AccountController.endorsements",
  67. parameters: [with_relationships_param(), id_param()],
  68. responses: %{
  69. 200 =>
  70. Operation.response(
  71. "Array of Accounts",
  72. "application/json",
  73. AccountOperation.array_of_accounts()
  74. ),
  75. 404 => Operation.response("Not Found", "application/json", ApiError)
  76. }
  77. }
  78. end
  79. def subscribe_operation do
  80. %Operation{
  81. tags: ["Account actions"],
  82. summary: "Subscribe",
  83. description: "Receive notifications for all statuses posted by the account.",
  84. operationId: "PleromaAPI.AccountController.subscribe",
  85. parameters: [id_param()],
  86. security: [%{"oAuth" => ["follow", "write:follows"]}],
  87. responses: %{
  88. 200 => Operation.response("Relationship", "application/json", AccountRelationship),
  89. 404 => Operation.response("Not Found", "application/json", ApiError)
  90. }
  91. }
  92. end
  93. def unsubscribe_operation do
  94. %Operation{
  95. tags: ["Account actions"],
  96. summary: "Unsubscribe",
  97. description: "Stop receiving notifications for all statuses posted by the account.",
  98. operationId: "PleromaAPI.AccountController.unsubscribe",
  99. parameters: [id_param()],
  100. security: [%{"oAuth" => ["follow", "write:follows"]}],
  101. responses: %{
  102. 200 => Operation.response("Relationship", "application/json", AccountRelationship),
  103. 404 => Operation.response("Not Found", "application/json", ApiError)
  104. }
  105. }
  106. end
  107. def birthdays_operation do
  108. %Operation{
  109. tags: ["Retrieve account information"],
  110. summary: "Birthday reminders",
  111. description: "Birthday reminders about users you follow.",
  112. operationId: "PleromaAPI.AccountController.birthdays",
  113. parameters: [
  114. Operation.parameter(
  115. :day,
  116. :query,
  117. %Schema{type: :integer},
  118. "Day of users' birthdays"
  119. ),
  120. Operation.parameter(
  121. :month,
  122. :query,
  123. %Schema{type: :integer},
  124. "Month of users' birthdays"
  125. )
  126. ],
  127. security: [%{"oAuth" => ["read:accounts"]}],
  128. responses: %{
  129. 200 =>
  130. Operation.response("Accounts", "application/json", AccountOperation.array_of_accounts())
  131. }
  132. }
  133. end
  134. defp id_param do
  135. Operation.parameter(:id, :path, FlakeID.schema(), "Account ID",
  136. example: "9umDrYheeY451cQnEe",
  137. required: true
  138. )
  139. end
  140. end