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