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