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