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