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