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