StatusView: implement pleroma.context field
[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 context: %Schema{
156 type: :string,
157 description: "The thread identifier the status is associated with"
158 },
159 conversation_id: %Schema{
160 type: :integer,
161 deprecated: true,
162 description: "The ID of the AP context the status is associated with (if any); deprecated, please use `context` instead"
163 },
164 direct_conversation_id: %Schema{
165 type: :integer,
166 nullable: true,
167 description:
168 "The ID of the Mastodon direct message conversation the status is associated with (if any)"
169 },
170 emoji_reactions: %Schema{
171 type: :array,
172 description:
173 "A list with emoji / reaction maps. Contains no information about the reacting users, for that use the /statuses/:id/reactions endpoint.",
174 items: %Schema{
175 type: :object,
176 properties: %{
177 name: %Schema{type: :string},
178 count: %Schema{type: :integer},
179 me: %Schema{type: :boolean}
180 }
181 }
182 },
183 expires_at: %Schema{
184 type: :string,
185 format: "date-time",
186 nullable: true,
187 description:
188 "A datetime (ISO 8601) that states when the post will expire (be deleted automatically), or empty if the post won't expire"
189 },
190 in_reply_to_account_acct: %Schema{
191 type: :string,
192 nullable: true,
193 description: "The `acct` property of User entity for replied user (if any)"
194 },
195 local: %Schema{
196 type: :boolean,
197 description: "`true` if the post was made on the local instance"
198 },
199 spoiler_text: %Schema{
200 type: :object,
201 additionalProperties: %Schema{type: :string},
202 description:
203 "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`."
204 },
205 thread_muted: %Schema{
206 type: :boolean,
207 description: "`true` if the thread the post belongs to is muted"
208 },
209 parent_visible: %Schema{
210 type: :boolean,
211 description: "`true` if the parent post is visible to the user"
212 },
213 pinned_at: %Schema{
214 type: :string,
215 format: "date-time",
216 nullable: true,
217 description:
218 "A datetime (ISO 8601) that states when the post was pinned or `null` if the post is not pinned"
219 }
220 }
221 },
222 akkoma: %Schema{
223 type: :object,
224 properties: %{
225 source: %Schema{
226 nullable: true,
227 oneOf: [
228 %Schema{type: :string, example: 'plaintext content'},
229 %Schema{
230 type: :object,
231 properties: %{
232 content: %Schema{
233 type: :string,
234 description: "The source content of the status",
235 nullable: true
236 },
237 mediaType: %Schema{
238 type: :string,
239 description: "The source MIME type of the status",
240 example: "text/plain",
241 nullable: true
242 }
243 }
244 }
245 ]
246 }
247 }
248 },
249 poll: %Schema{allOf: [Poll], nullable: true, description: "The poll attached to the status"},
250 reblog: %Schema{
251 allOf: [%OpenApiSpex.Reference{"$ref": "#/components/schemas/Status"}],
252 nullable: true,
253 description: "The status being reblogged"
254 },
255 reblogged: %Schema{type: :boolean, description: "Have you boosted this status?"},
256 reblogs_count: %Schema{
257 type: :integer,
258 description: "How many boosts this status has received"
259 },
260 replies_count: %Schema{
261 type: :integer,
262 description: "How many replies this status has received"
263 },
264 sensitive: %Schema{
265 type: :boolean,
266 description: "Is this status marked as sensitive content?"
267 },
268 spoiler_text: %Schema{
269 type: :string,
270 description:
271 "Subject or summary line, below which status content is collapsed until expanded"
272 },
273 tags: %Schema{type: :array, items: Tag},
274 uri: %Schema{
275 type: :string,
276 format: :uri,
277 description: "URI of the status used for federation"
278 },
279 url: %Schema{
280 type: :string,
281 nullable: true,
282 format: :uri,
283 description: "A link to the status's HTML representation"
284 },
285 visibility: %Schema{
286 allOf: [VisibilityScope],
287 description: "Visibility of this status"
288 }
289 },
290 example: %{
291 "account" => %{
292 "acct" => "nick6",
293 "avatar" => "http://localhost:4001/images/avi.png",
294 "avatar_static" => "http://localhost:4001/images/avi.png",
295 "bot" => false,
296 "created_at" => "2020-04-07T19:48:51.000Z",
297 "display_name" => "Test テスト User 6",
298 "emojis" => [],
299 "fields" => [],
300 "followers_count" => 1,
301 "following_count" => 0,
302 "header" => "http://localhost:4001/images/banner.png",
303 "header_static" => "http://localhost:4001/images/banner.png",
304 "id" => "9toJCsKN7SmSf3aj5c",
305 "is_locked" => false,
306 "note" => "Tester Number 6",
307 "pleroma" => %{
308 "background_image" => nil,
309 "is_confirmed" => true,
310 "hide_favorites" => true,
311 "hide_followers" => false,
312 "hide_followers_count" => false,
313 "hide_follows" => false,
314 "hide_follows_count" => false,
315 "is_admin" => false,
316 "is_moderator" => false,
317 "relationship" => %{
318 "blocked_by" => false,
319 "blocking" => false,
320 "domain_blocking" => false,
321 "endorsed" => false,
322 "followed_by" => false,
323 "following" => true,
324 "id" => "9toJCsKN7SmSf3aj5c",
325 "muting" => false,
326 "muting_notifications" => false,
327 "note" => "",
328 "requested" => false,
329 "showing_reblogs" => true,
330 "subscribing" => false,
331 "notifying" => false
332 },
333 "skip_thread_containment" => false,
334 "tags" => []
335 },
336 "source" => %{
337 "fields" => [],
338 "note" => "Tester Number 6",
339 "pleroma" => %{"actor_type" => "Person", "discoverable" => false},
340 "sensitive" => false
341 },
342 "statuses_count" => 1,
343 "url" => "http://localhost:4001/users/nick6",
344 "username" => "nick6"
345 },
346 "application" => nil,
347 "bookmarked" => false,
348 "card" => nil,
349 "content" => "foobar",
350 "created_at" => "2020-04-07T19:48:51.000Z",
351 "emojis" => [],
352 "favourited" => false,
353 "favourites_count" => 0,
354 "id" => "9toJCu5YZW7O7gfvH6",
355 "in_reply_to_account_id" => nil,
356 "in_reply_to_id" => nil,
357 "language" => nil,
358 "media_attachments" => [],
359 "mentions" => [],
360 "muted" => false,
361 "pinned" => false,
362 "pleroma" => %{
363 "content" => %{"text/plain" => "foobar"},
364 "context" => "http://localhost:4001/objects/8b4c0c80-6a37-4d2a-b1b9-05a19e3875aa",
365 "conversation_id" => 345_972,
366 "direct_conversation_id" => nil,
367 "emoji_reactions" => [],
368 "expires_at" => nil,
369 "in_reply_to_account_acct" => nil,
370 "local" => true,
371 "spoiler_text" => %{"text/plain" => ""},
372 "thread_muted" => false
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