1 defmodule Pleroma.User.Info do
6 field(:banner, :map, default: %{})
7 field(:background, :map, default: %{})
8 field(:source_data, :map, default: %{})
9 field(:note_count, :integer, default: 0)
10 field(:follower_count, :integer, default: 0)
11 field(:locked, :boolean, default: false)
12 field(:default_scope, :string, default: "public")
13 field(:blocks, {:array, :string}, default: [])
14 field(:domain_blocks, {:array, :string}, default: [])
15 field(:deactivated, :boolean, default: false)
16 field(:no_rich_text, :boolean, default: false)
17 field(:ap_enabled, :boolean, default: false)
18 field(:is_moderator, :boolean, default: false)
19 field(:is_admin, :boolean, default: false)
20 field(:keys, :string, default: nil)
21 field(:settings, :map, default: nil)
22 field(:magic_key, :string, default: nil)
23 field(:uri, :string, default: nil)
24 field(:topic, :string, default: nil)
25 field(:hub, :string, default: nil)
26 field(:salmon, :string, default: nil)
27 field(:hide_network, :boolean, default: false)
30 # ap_id -> Where is this used?
31 # bio -> Where is this used?
32 # avatar -> Where is this used?
33 # fqn -> Where is this used?
34 # host -> Where is this used?
35 # subject _> Where is this used?
38 def set_activation_status(info, deactivated) do
39 params = %{deactivated: deactivated}
42 |> cast(params, [:deactivated])
43 |> validate_required([:deactivated])
46 def add_to_note_count(info, number) do
47 set_note_count(info, info.note_count + number)
50 def set_note_count(info, number) do
51 params = %{note_count: Enum.max([0, number])}
54 |> cast(params, [:note_count])
55 |> validate_required([:note_count])
58 def set_follower_count(info, number) do
59 params = %{follower_count: Enum.max([0, number])}
62 |> cast(params, [:follower_count])
63 |> validate_required([:follower_count])
66 def set_blocks(info, blocks) do
67 params = %{blocks: blocks}
70 |> cast(params, [:blocks])
71 |> validate_required([:blocks])
74 def add_to_block(info, blocked) do
75 set_blocks(info, Enum.uniq([blocked | info.blocks]))
78 def remove_from_block(info, blocked) do
79 set_blocks(info, List.delete(info.blocks, blocked))
82 def set_domain_blocks(info, domain_blocks) do
83 params = %{domain_blocks: domain_blocks}
86 |> cast(params, [:domain_blocks])
87 |> validate_required([:domain_blocks])
90 def add_to_domain_block(info, domain_blocked) do
91 set_domain_blocks(info, Enum.uniq([domain_blocked | info.domain_blocks]))
94 def remove_from_domain_block(info, domain_blocked) do
95 set_domain_blocks(info, List.delete(info.domain_blocks, domain_blocked))
98 def set_keys(info, keys) do
99 params = %{keys: keys}
102 |> cast(params, [:keys])
103 |> validate_required([:keys])
106 def remote_user_creation(info, params) do
121 def user_upgrade(info, params) do
132 def profile_update(info, params) do
144 def mastodon_profile_update(info, params) do
152 def mastodon_settings_update(info, params) do
154 |> cast(params, [:settings])
157 def set_source_data(info, source_data) do
158 params = %{source_data: source_data}
161 |> cast(params, [:source_data])
162 |> validate_required([:source_data])
165 def admin_api_update(info, params) do