Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

343 lines
12KB

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.ApiSpec.Schemas.Status do
  5. alias OpenApiSpex.Schema
  6. alias Pleroma.Web.ApiSpec.Schemas.Account
  7. alias Pleroma.Web.ApiSpec.Schemas.Attachment
  8. alias Pleroma.Web.ApiSpec.Schemas.Emoji
  9. alias Pleroma.Web.ApiSpec.Schemas.FlakeID
  10. alias Pleroma.Web.ApiSpec.Schemas.Poll
  11. alias Pleroma.Web.ApiSpec.Schemas.Tag
  12. alias Pleroma.Web.ApiSpec.Schemas.VisibilityScope
  13. require OpenApiSpex
  14. OpenApiSpex.schema(%{
  15. title: "Status",
  16. description: "Response schema for a status",
  17. type: :object,
  18. properties: %{
  19. account: %Schema{allOf: [Account], description: "The account that authored this status"},
  20. application: %Schema{
  21. description: "The application used to post this status",
  22. type: :object,
  23. nullable: true,
  24. properties: %{
  25. name: %Schema{type: :string},
  26. website: %Schema{type: :string, format: :uri}
  27. }
  28. },
  29. bookmarked: %Schema{type: :boolean, description: "Have you bookmarked this status?"},
  30. card: %Schema{
  31. type: :object,
  32. nullable: true,
  33. description: "Preview card for links included within status content",
  34. required: [:url, :title, :description, :type],
  35. properties: %{
  36. type: %Schema{
  37. type: :string,
  38. enum: ["link", "photo", "video", "rich"],
  39. description: "The type of the preview card"
  40. },
  41. provider_name: %Schema{
  42. type: :string,
  43. nullable: true,
  44. description: "The provider of the original resource"
  45. },
  46. provider_url: %Schema{
  47. type: :string,
  48. format: :uri,
  49. description: "A link to the provider of the original resource"
  50. },
  51. url: %Schema{type: :string, format: :uri, description: "Location of linked resource"},
  52. image: %Schema{
  53. type: :string,
  54. nullable: true,
  55. format: :uri,
  56. description: "Preview thumbnail"
  57. },
  58. title: %Schema{type: :string, description: "Title of linked resource"},
  59. description: %Schema{type: :string, description: "Description of preview"}
  60. }
  61. },
  62. content: %Schema{type: :string, format: :html, description: "HTML-encoded status content"},
  63. text: %Schema{
  64. type: :string,
  65. description: "Original unformatted content in plain text",
  66. nullable: true
  67. },
  68. created_at: %Schema{
  69. type: :string,
  70. format: "date-time",
  71. description: "The date when this status was created"
  72. },
  73. emojis: %Schema{
  74. type: :array,
  75. items: Emoji,
  76. description: "Custom emoji to be used when rendering status content"
  77. },
  78. favourited: %Schema{type: :boolean, description: "Have you favourited this status?"},
  79. favourites_count: %Schema{
  80. type: :integer,
  81. description: "How many favourites this status has received"
  82. },
  83. id: FlakeID,
  84. in_reply_to_account_id: %Schema{
  85. allOf: [FlakeID],
  86. nullable: true,
  87. description: "ID of the account being replied to"
  88. },
  89. in_reply_to_id: %Schema{
  90. allOf: [FlakeID],
  91. nullable: true,
  92. description: "ID of the status being replied"
  93. },
  94. language: %Schema{
  95. type: :string,
  96. nullable: true,
  97. description: "Primary language of this status"
  98. },
  99. media_attachments: %Schema{
  100. type: :array,
  101. items: Attachment,
  102. description: "Media that is attached to this status"
  103. },
  104. mentions: %Schema{
  105. type: :array,
  106. description: "Mentions of users within the status content",
  107. items: %Schema{
  108. type: :object,
  109. properties: %{
  110. id: %Schema{allOf: [FlakeID], description: "The account id of the mentioned user"},
  111. acct: %Schema{
  112. type: :string,
  113. description:
  114. "The webfinger acct: URI of the mentioned user. Equivalent to `username` for local users, or `username@domain` for remote users."
  115. },
  116. username: %Schema{type: :string, description: "The username of the mentioned user"},
  117. url: %Schema{
  118. type: :string,
  119. format: :uri,
  120. description: "The location of the mentioned user's profile"
  121. }
  122. }
  123. }
  124. },
  125. muted: %Schema{
  126. type: :boolean,
  127. description: "Have you muted notifications for this status's conversation?"
  128. },
  129. pinned: %Schema{
  130. type: :boolean,
  131. description: "Have you pinned this status? Only appears if the status is pinnable."
  132. },
  133. pleroma: %Schema{
  134. type: :object,
  135. properties: %{
  136. content: %Schema{
  137. type: :object,
  138. additionalProperties: %Schema{type: :string},
  139. description:
  140. "A map consisting of alternate representations of the `content` property with the key being it's mimetype. Currently the only alternate representation supported is `text/plain`"
  141. },
  142. conversation_id: %Schema{
  143. type: :integer,
  144. description: "The ID of the AP context the status is associated with (if any)"
  145. },
  146. direct_conversation_id: %Schema{
  147. type: :integer,
  148. nullable: true,
  149. description:
  150. "The ID of the Mastodon direct message conversation the status is associated with (if any)"
  151. },
  152. emoji_reactions: %Schema{
  153. type: :array,
  154. description:
  155. "A list with emoji / reaction maps. Contains no information about the reacting users, for that use the /statuses/:id/reactions endpoint.",
  156. items: %Schema{
  157. type: :object,
  158. properties: %{
  159. name: %Schema{type: :string},
  160. count: %Schema{type: :integer},
  161. me: %Schema{type: :boolean}
  162. }
  163. }
  164. },
  165. expires_at: %Schema{
  166. type: :string,
  167. format: "date-time",
  168. nullable: true,
  169. description:
  170. "A datetime (ISO 8601) that states when the post will expire (be deleted automatically), or empty if the post won't expire"
  171. },
  172. in_reply_to_account_acct: %Schema{
  173. type: :string,
  174. nullable: true,
  175. description: "The `acct` property of User entity for replied user (if any)"
  176. },
  177. local: %Schema{
  178. type: :boolean,
  179. description: "`true` if the post was made on the local instance"
  180. },
  181. spoiler_text: %Schema{
  182. type: :object,
  183. additionalProperties: %Schema{type: :string},
  184. description:
  185. "A map consisting of alternate representations of the `spoiler_text` property with the key being it's mimetype. Currently the only alternate representation supported is `text/plain`."
  186. },
  187. thread_muted: %Schema{
  188. type: :boolean,
  189. description: "`true` if the thread the post belongs to is muted"
  190. },
  191. parent_visible: %Schema{
  192. type: :boolean,
  193. description: "`true` if the parent post is visible to the user"
  194. },
  195. pinned_at: %Schema{
  196. type: :string,
  197. format: "date-time",
  198. nullable: true,
  199. description:
  200. "A datetime (ISO 8601) that states when the post was pinned or `null` if the post is not pinned"
  201. }
  202. }
  203. },
  204. poll: %Schema{allOf: [Poll], nullable: true, description: "The poll attached to the status"},
  205. reblog: %Schema{
  206. allOf: [%OpenApiSpex.Reference{"$ref": "#/components/schemas/Status"}],
  207. nullable: true,
  208. description: "The status being reblogged"
  209. },
  210. reblogged: %Schema{type: :boolean, description: "Have you boosted this status?"},
  211. reblogs_count: %Schema{
  212. type: :integer,
  213. description: "How many boosts this status has received"
  214. },
  215. replies_count: %Schema{
  216. type: :integer,
  217. description: "How many replies this status has received"
  218. },
  219. sensitive: %Schema{
  220. type: :boolean,
  221. description: "Is this status marked as sensitive content?"
  222. },
  223. spoiler_text: %Schema{
  224. type: :string,
  225. description:
  226. "Subject or summary line, below which status content is collapsed until expanded"
  227. },
  228. tags: %Schema{type: :array, items: Tag},
  229. uri: %Schema{
  230. type: :string,
  231. format: :uri,
  232. description: "URI of the status used for federation"
  233. },
  234. url: %Schema{
  235. type: :string,
  236. nullable: true,
  237. format: :uri,
  238. description: "A link to the status's HTML representation"
  239. },
  240. visibility: %Schema{
  241. allOf: [VisibilityScope],
  242. description: "Visibility of this status"
  243. }
  244. },
  245. example: %{
  246. "account" => %{
  247. "acct" => "nick6",
  248. "avatar" => "http://localhost:4001/images/avi.png",
  249. "avatar_static" => "http://localhost:4001/images/avi.png",
  250. "bot" => false,
  251. "created_at" => "2020-04-07T19:48:51.000Z",
  252. "display_name" => "Test テスト User 6",
  253. "emojis" => [],
  254. "fields" => [],
  255. "followers_count" => 1,
  256. "following_count" => 0,
  257. "header" => "http://localhost:4001/images/banner.png",
  258. "header_static" => "http://localhost:4001/images/banner.png",
  259. "id" => "9toJCsKN7SmSf3aj5c",
  260. "is_locked" => false,
  261. "note" => "Tester Number 6",
  262. "pleroma" => %{
  263. "background_image" => nil,
  264. "is_confirmed" => true,
  265. "hide_favorites" => true,
  266. "hide_followers" => false,
  267. "hide_followers_count" => false,
  268. "hide_follows" => false,
  269. "hide_follows_count" => false,
  270. "is_admin" => false,
  271. "is_moderator" => false,
  272. "relationship" => %{
  273. "blocked_by" => false,
  274. "blocking" => false,
  275. "domain_blocking" => false,
  276. "endorsed" => false,
  277. "followed_by" => false,
  278. "following" => true,
  279. "id" => "9toJCsKN7SmSf3aj5c",
  280. "muting" => false,
  281. "muting_notifications" => false,
  282. "requested" => false,
  283. "showing_reblogs" => true,
  284. "subscribing" => false
  285. },
  286. "skip_thread_containment" => false,
  287. "tags" => []
  288. },
  289. "source" => %{
  290. "fields" => [],
  291. "note" => "Tester Number 6",
  292. "pleroma" => %{"actor_type" => "Person", "discoverable" => false},
  293. "sensitive" => false
  294. },
  295. "statuses_count" => 1,
  296. "url" => "http://localhost:4001/users/nick6",
  297. "username" => "nick6"
  298. },
  299. "application" => nil,
  300. "bookmarked" => false,
  301. "card" => nil,
  302. "content" => "foobar",
  303. "created_at" => "2020-04-07T19:48:51.000Z",
  304. "emojis" => [],
  305. "favourited" => false,
  306. "favourites_count" => 0,
  307. "id" => "9toJCu5YZW7O7gfvH6",
  308. "in_reply_to_account_id" => nil,
  309. "in_reply_to_id" => nil,
  310. "language" => nil,
  311. "media_attachments" => [],
  312. "mentions" => [],
  313. "muted" => false,
  314. "pinned" => false,
  315. "pleroma" => %{
  316. "content" => %{"text/plain" => "foobar"},
  317. "conversation_id" => 345_972,
  318. "direct_conversation_id" => nil,
  319. "emoji_reactions" => [],
  320. "expires_at" => nil,
  321. "in_reply_to_account_acct" => nil,
  322. "local" => true,
  323. "spoiler_text" => %{"text/plain" => ""},
  324. "thread_muted" => false
  325. },
  326. "poll" => nil,
  327. "reblog" => nil,
  328. "reblogged" => false,
  329. "reblogs_count" => 0,
  330. "replies_count" => 0,
  331. "sensitive" => false,
  332. "spoiler_text" => "",
  333. "tags" => [],
  334. "uri" => "http://localhost:4001/objects/0f5dad44-0e9e-4610-b377-a2631e499190",
  335. "url" => "http://localhost:4001/notice/9toJCu5YZW7O7gfvH6",
  336. "visibility" => "private"
  337. }
  338. })
  339. end