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