First
[anni] / lib / pleroma / web / api_spec / schemas / account.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.Account do
6   alias OpenApiSpex.Schema
7   alias Pleroma.Web.ApiSpec.Schemas.AccountField
8   alias Pleroma.Web.ApiSpec.Schemas.AccountRelationship
9   alias Pleroma.Web.ApiSpec.Schemas.ActorType
10   alias Pleroma.Web.ApiSpec.Schemas.Emoji
11   alias Pleroma.Web.ApiSpec.Schemas.FlakeID
12   alias Pleroma.Web.ApiSpec.Schemas.VisibilityScope
13
14   require OpenApiSpex
15
16   OpenApiSpex.schema(%{
17     title: "Account",
18     description: "Response schema for an account",
19     type: :object,
20     properties: %{
21       acct: %Schema{type: :string},
22       avatar_static: %Schema{type: :string, format: :uri},
23       avatar: %Schema{type: :string, format: :uri},
24       bot: %Schema{type: :boolean},
25       created_at: %Schema{type: :string, format: "date-time"},
26       display_name: %Schema{type: :string},
27       emojis: %Schema{type: :array, items: Emoji},
28       fields: %Schema{type: :array, items: AccountField},
29       follow_requests_count: %Schema{type: :integer},
30       followers_count: %Schema{type: :integer},
31       following_count: %Schema{type: :integer},
32       header_static: %Schema{type: :string, format: :uri},
33       header: %Schema{type: :string, format: :uri},
34       id: FlakeID,
35       locked: %Schema{type: :boolean},
36       mute_expires_at: %Schema{type: :string, format: "date-time", nullable: true},
37       note: %Schema{type: :string, format: :html},
38       statuses_count: %Schema{type: :integer},
39       url: %Schema{type: :string, format: :uri},
40       username: %Schema{type: :string},
41       pleroma: %Schema{
42         type: :object,
43         properties: %{
44           ap_id: %Schema{type: :string},
45           also_known_as: %Schema{type: :array, items: %Schema{type: :string}},
46           allow_following_move: %Schema{
47             type: :boolean,
48             description: "whether the user allows automatically follow moved following accounts"
49           },
50           background_image: %Schema{type: :string, nullable: true, format: :uri},
51           birthday: %Schema{type: :string, nullable: true, format: :date},
52           chat_token: %Schema{type: :string},
53           is_confirmed: %Schema{
54             type: :boolean,
55             description:
56               "whether the user account is waiting on email confirmation to be activated"
57           },
58           show_birthday: %Schema{type: :boolean, nullable: true},
59           hide_favorites: %Schema{type: :boolean},
60           hide_followers_count: %Schema{
61             type: :boolean,
62             description: "whether the user has follower stat hiding enabled"
63           },
64           hide_followers: %Schema{
65             type: :boolean,
66             description: "whether the user has follower hiding enabled"
67           },
68           hide_follows_count: %Schema{
69             type: :boolean,
70             description: "whether the user has follow stat hiding enabled"
71           },
72           hide_follows: %Schema{
73             type: :boolean,
74             description: "whether the user has follow hiding enabled"
75           },
76           is_admin: %Schema{
77             type: :boolean,
78             description: "whether the user is an admin of the local instance"
79           },
80           is_moderator: %Schema{
81             type: :boolean,
82             description: "whether the user is a moderator of the local instance"
83           },
84           skip_thread_containment: %Schema{type: :boolean},
85           tags: %Schema{
86             type: :array,
87             items: %Schema{type: :string},
88             description:
89               "List of tags being used for things like extra roles or moderation(ie. marking all media as nsfw all)."
90           },
91           unread_conversation_count: %Schema{
92             type: :integer,
93             description: "The count of unread conversations. Only returned to the account owner."
94           },
95           notification_settings: %Schema{
96             type: :object,
97             properties: %{
98               block_from_strangers: %Schema{type: :boolean},
99               hide_notification_contents: %Schema{type: :boolean}
100             }
101           },
102           relationship: %Schema{allOf: [AccountRelationship], nullable: true},
103           settings_store: %Schema{
104             type: :object,
105             description:
106               "A generic map of settings for frontends. Opaque to the backend. Only returned in `verify_credentials` and `update_credentials`"
107           },
108           accepts_chat_messages: %Schema{type: :boolean, nullable: true},
109           favicon: %Schema{
110             type: :string,
111             format: :uri,
112             nullable: true,
113             description: "Favicon image of the user's instance"
114           }
115         }
116       },
117       source: %Schema{
118         type: :object,
119         properties: %{
120           fields: %Schema{type: :array, items: AccountField},
121           note: %Schema{
122             type: :string,
123             description:
124               "Plaintext version of the bio without formatting applied by the backend, used for editing the bio."
125           },
126           privacy: VisibilityScope,
127           sensitive: %Schema{type: :boolean},
128           pleroma: %Schema{
129             type: :object,
130             properties: %{
131               actor_type: ActorType,
132               discoverable: %Schema{
133                 type: :boolean,
134                 description:
135                   "whether the user allows indexing / listing of the account by external services (search engines etc.)."
136               },
137               no_rich_text: %Schema{
138                 type: :boolean,
139                 description:
140                   "whether the HTML tags for rich-text formatting are stripped from all statuses requested from the API."
141               },
142               show_role: %Schema{
143                 type: :boolean,
144                 description:
145                   "whether the user wants their role (e.g admin, moderator) to be shown"
146               }
147             }
148           }
149         }
150       }
151     },
152     example: %{
153       "acct" => "foobar",
154       "avatar" => "https://mypleroma.com/images/avi.png",
155       "avatar_static" => "https://mypleroma.com/images/avi.png",
156       "bot" => false,
157       "created_at" => "2020-03-24T13:05:58.000Z",
158       "display_name" => "foobar",
159       "emojis" => [],
160       "fields" => [],
161       "follow_requests_count" => 0,
162       "followers_count" => 0,
163       "following_count" => 1,
164       "header" => "https://mypleroma.com/images/banner.png",
165       "header_static" => "https://mypleroma.com/images/banner.png",
166       "id" => "9tKi3esbG7OQgZ2920",
167       "locked" => false,
168       "note" => "cofe",
169       "pleroma" => %{
170         "allow_following_move" => true,
171         "background_image" => nil,
172         "is_confirmed" => false,
173         "hide_favorites" => true,
174         "hide_followers" => false,
175         "hide_followers_count" => false,
176         "hide_follows" => false,
177         "hide_follows_count" => false,
178         "is_admin" => false,
179         "is_moderator" => false,
180         "skip_thread_containment" => false,
181         "accepts_chat_messages" => true,
182         "chat_token" =>
183           "SFMyNTY.g3QAAAACZAAEZGF0YW0AAAASOXRLaTNlc2JHN09RZ1oyOTIwZAAGc2lnbmVkbgYARNplS3EB.Mb_Iaqew2bN1I1o79B_iP7encmVCpTKC4OtHZRxdjKc",
184         "unread_conversation_count" => 0,
185         "tags" => [],
186         "notification_settings" => %{
187           "block_from_strangers" => false,
188           "hide_notification_contents" => false
189         },
190         "relationship" => %{
191           "blocked_by" => false,
192           "blocking" => false,
193           "domain_blocking" => false,
194           "endorsed" => false,
195           "followed_by" => false,
196           "following" => false,
197           "id" => "9tKi3esbG7OQgZ2920",
198           "muting" => false,
199           "muting_notifications" => false,
200           "note" => "",
201           "requested" => false,
202           "showing_reblogs" => true,
203           "subscribing" => false,
204           "notifying" => false
205         },
206         "settings_store" => %{
207           "pleroma-fe" => %{}
208         },
209         "birthday" => "2001-02-12"
210       },
211       "source" => %{
212         "fields" => [],
213         "note" => "foobar",
214         "pleroma" => %{
215           "actor_type" => "Person",
216           "discoverable" => false,
217           "no_rich_text" => false,
218           "show_role" => true
219         },
220         "privacy" => "public",
221         "sensitive" => false
222       },
223       "statuses_count" => 0,
224       "url" => "https://mypleroma.com/users/foobar",
225       "username" => "foobar"
226     }
227   })
228 end