logo

pleroma

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

status.ex (14105B)


  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.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. edited_at: %Schema{
  74. type: :string,
  75. format: "date-time",
  76. nullable: true,
  77. description: "The date when this status was last edited"
  78. },
  79. emojis: %Schema{
  80. type: :array,
  81. items: Emoji,
  82. description: "Custom emoji to be used when rendering status content"
  83. },
  84. favourited: %Schema{type: :boolean, description: "Have you favourited this status?"},
  85. favourites_count: %Schema{
  86. type: :integer,
  87. description: "How many favourites this status has received"
  88. },
  89. id: FlakeID,
  90. in_reply_to_account_id: %Schema{
  91. allOf: [FlakeID],
  92. nullable: true,
  93. description: "ID of the account being replied to"
  94. },
  95. in_reply_to_id: %Schema{
  96. allOf: [FlakeID],
  97. nullable: true,
  98. description: "ID of the status being replied"
  99. },
  100. language: %Schema{
  101. type: :string,
  102. nullable: true,
  103. description: "Primary language of this status"
  104. },
  105. media_attachments: %Schema{
  106. type: :array,
  107. items: Attachment,
  108. description: "Media that is attached to this status"
  109. },
  110. mentions: %Schema{
  111. type: :array,
  112. description: "Mentions of users within the status content",
  113. items: %Schema{
  114. type: :object,
  115. properties: %{
  116. id: %Schema{allOf: [FlakeID], description: "The account id of the mentioned user"},
  117. acct: %Schema{
  118. type: :string,
  119. description:
  120. "The webfinger acct: URI of the mentioned user. Equivalent to `username` for local users, or `username@domain` for remote users."
  121. },
  122. username: %Schema{type: :string, description: "The username of the mentioned user"},
  123. url: %Schema{
  124. type: :string,
  125. format: :uri,
  126. description: "The location of the mentioned user's profile"
  127. }
  128. }
  129. }
  130. },
  131. muted: %Schema{
  132. type: :boolean,
  133. description: "Have you muted notifications for this status's conversation?"
  134. },
  135. pinned: %Schema{
  136. type: :boolean,
  137. description: "Have you pinned this status? Only appears if the status is pinnable."
  138. },
  139. pleroma: %Schema{
  140. type: :object,
  141. properties: %{
  142. content: %Schema{
  143. type: :object,
  144. additionalProperties: %Schema{
  145. type: :string,
  146. description: "Alternate representation in the MIME type specified",
  147. extensions: %{"x-additionalPropertiesName": "MIME type"}
  148. },
  149. description:
  150. "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`"
  151. },
  152. context: %Schema{
  153. type: :string,
  154. description: "The thread identifier the status is associated with"
  155. },
  156. conversation_id: %Schema{
  157. type: :integer,
  158. deprecated: true,
  159. description:
  160. "The ID of the AP context the status is associated with (if any); deprecated, please use `context` instead"
  161. },
  162. direct_conversation_id: %Schema{
  163. type: :integer,
  164. nullable: true,
  165. description:
  166. "The ID of the Mastodon direct message conversation the status is associated with (if any)"
  167. },
  168. emoji_reactions: %Schema{
  169. type: :array,
  170. description:
  171. "A list with emoji / reaction maps. Contains no information about the reacting users, for that use the /statuses/:id/reactions endpoint.",
  172. items: %Schema{
  173. type: :object,
  174. properties: %{
  175. name: %Schema{type: :string},
  176. count: %Schema{type: :integer},
  177. me: %Schema{type: :boolean}
  178. }
  179. }
  180. },
  181. expires_at: %Schema{
  182. type: :string,
  183. format: "date-time",
  184. nullable: true,
  185. description:
  186. "A datetime (ISO 8601) that states when the post will expire (be deleted automatically), or empty if the post won't expire"
  187. },
  188. in_reply_to_account_acct: %Schema{
  189. type: :string,
  190. nullable: true,
  191. description: "The `acct` property of User entity for replied user (if any)"
  192. },
  193. quote: %Schema{
  194. allOf: [%OpenApiSpex.Reference{"$ref": "#/components/schemas/Status"}],
  195. nullable: true,
  196. description: "Quoted status (if any)"
  197. },
  198. quote_id: %Schema{
  199. nullable: true,
  200. allOf: [FlakeID],
  201. description: "ID of the status being quoted, if any"
  202. },
  203. quote_url: %Schema{
  204. type: :string,
  205. format: :uri,
  206. nullable: true,
  207. description: "URL of the quoted status"
  208. },
  209. quote_visible: %Schema{
  210. type: :boolean,
  211. description: "`true` if the quoted post is visible to the user"
  212. },
  213. quotes_count: %Schema{
  214. type: :integer,
  215. description: "How many statuses quoted this status"
  216. },
  217. local: %Schema{
  218. type: :boolean,
  219. description: "`true` if the post was made on the local instance"
  220. },
  221. spoiler_text: %Schema{
  222. type: :object,
  223. additionalProperties: %Schema{
  224. type: :string,
  225. description: "Alternate representation in the MIME type specified",
  226. extensions: %{"x-additionalPropertiesName": "MIME type"}
  227. },
  228. description:
  229. "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`."
  230. },
  231. thread_muted: %Schema{
  232. type: :boolean,
  233. description: "`true` if the thread the post belongs to is muted"
  234. },
  235. parent_visible: %Schema{
  236. type: :boolean,
  237. description: "`true` if the parent post is visible to the user"
  238. },
  239. pinned_at: %Schema{
  240. type: :string,
  241. format: "date-time",
  242. nullable: true,
  243. description:
  244. "A datetime (ISO 8601) that states when the post was pinned or `null` if the post is not pinned"
  245. }
  246. }
  247. },
  248. poll: %Schema{allOf: [Poll], nullable: true, description: "The poll attached to the status"},
  249. reblog: %Schema{
  250. allOf: [%OpenApiSpex.Reference{"$ref": "#/components/schemas/Status"}],
  251. nullable: true,
  252. description: "The status being reblogged"
  253. },
  254. reblogged: %Schema{type: :boolean, description: "Have you boosted this status?"},
  255. reblogs_count: %Schema{
  256. type: :integer,
  257. description: "How many boosts this status has received"
  258. },
  259. replies_count: %Schema{
  260. type: :integer,
  261. description: "How many replies this status has received"
  262. },
  263. sensitive: %Schema{
  264. type: :boolean,
  265. description: "Is this status marked as sensitive content?"
  266. },
  267. spoiler_text: %Schema{
  268. type: :string,
  269. description:
  270. "Subject or summary line, below which status content is collapsed until expanded"
  271. },
  272. tags: %Schema{type: :array, items: Tag},
  273. uri: %Schema{
  274. type: :string,
  275. format: :uri,
  276. description: "URI of the status used for federation"
  277. },
  278. url: %Schema{
  279. type: :string,
  280. nullable: true,
  281. format: :uri,
  282. description: "A link to the status's HTML representation"
  283. },
  284. visibility: %Schema{
  285. allOf: [VisibilityScope],
  286. description: "Visibility of this status"
  287. }
  288. },
  289. example: %{
  290. "account" => %{
  291. "acct" => "nick6",
  292. "avatar" => "http://localhost:4001/images/avi.png",
  293. "avatar_static" => "http://localhost:4001/images/avi.png",
  294. "bot" => false,
  295. "created_at" => "2020-04-07T19:48:51.000Z",
  296. "display_name" => "Test テスト User 6",
  297. "emojis" => [],
  298. "fields" => [],
  299. "followers_count" => 1,
  300. "following_count" => 0,
  301. "header" => "http://localhost:4001/images/banner.png",
  302. "header_static" => "http://localhost:4001/images/banner.png",
  303. "id" => "9toJCsKN7SmSf3aj5c",
  304. "is_locked" => false,
  305. "note" => "Tester Number 6",
  306. "pleroma" => %{
  307. "background_image" => nil,
  308. "is_confirmed" => true,
  309. "hide_favorites" => true,
  310. "hide_followers" => false,
  311. "hide_followers_count" => false,
  312. "hide_follows" => false,
  313. "hide_follows_count" => false,
  314. "is_admin" => false,
  315. "is_moderator" => false,
  316. "relationship" => %{
  317. "blocked_by" => false,
  318. "blocking" => false,
  319. "domain_blocking" => false,
  320. "endorsed" => false,
  321. "followed_by" => false,
  322. "following" => true,
  323. "id" => "9toJCsKN7SmSf3aj5c",
  324. "muting" => false,
  325. "muting_notifications" => false,
  326. "note" => "",
  327. "requested" => false,
  328. "showing_reblogs" => true,
  329. "subscribing" => false,
  330. "notifying" => false
  331. },
  332. "skip_thread_containment" => false,
  333. "tags" => []
  334. },
  335. "source" => %{
  336. "fields" => [],
  337. "note" => "Tester Number 6",
  338. "pleroma" => %{"actor_type" => "Person", "discoverable" => false},
  339. "sensitive" => false
  340. },
  341. "statuses_count" => 1,
  342. "url" => "http://localhost:4001/users/nick6",
  343. "username" => "nick6"
  344. },
  345. "application" => nil,
  346. "bookmarked" => false,
  347. "card" => nil,
  348. "content" => "foobar",
  349. "created_at" => "2020-04-07T19:48:51.000Z",
  350. "emojis" => [],
  351. "favourited" => false,
  352. "favourites_count" => 0,
  353. "id" => "9toJCu5YZW7O7gfvH6",
  354. "in_reply_to_account_id" => nil,
  355. "in_reply_to_id" => nil,
  356. "language" => nil,
  357. "media_attachments" => [],
  358. "mentions" => [],
  359. "muted" => false,
  360. "pinned" => false,
  361. "pleroma" => %{
  362. "content" => %{"text/plain" => "foobar"},
  363. "context" => "http://localhost:4001/objects/8b4c0c80-6a37-4d2a-b1b9-05a19e3875aa",
  364. "conversation_id" => 345_972,
  365. "direct_conversation_id" => nil,
  366. "emoji_reactions" => [],
  367. "expires_at" => nil,
  368. "in_reply_to_account_acct" => nil,
  369. "local" => true,
  370. "spoiler_text" => %{"text/plain" => ""},
  371. "thread_muted" => false,
  372. "quotes_count" => 0
  373. },
  374. "poll" => nil,
  375. "reblog" => nil,
  376. "reblogged" => false,
  377. "reblogs_count" => 0,
  378. "replies_count" => 0,
  379. "sensitive" => false,
  380. "spoiler_text" => "",
  381. "tags" => [],
  382. "uri" => "http://localhost:4001/objects/0f5dad44-0e9e-4610-b377-a2631e499190",
  383. "url" => "http://localhost:4001/notice/9toJCu5YZW7O7gfvH6",
  384. "visibility" => "private"
  385. }
  386. })
  387. end