X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fuser%2Finfo.ex;h=818b646454993b1e4fa472bfdbd3f2b692856a02;hb=8ddbedcd9aa4ac795c64c7b9540e5c83185da414;hp=71848d91ed6df591da9dbc4a74ef98cd3dd90c05;hpb=89fbed88212657e3dcd4bbcb2c0718b07802037f;p=akkoma
diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex
index 71848d91e..818b64645 100644
--- a/lib/pleroma/user/info.ex
+++ b/lib/pleroma/user/info.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2018 Pleroma Authors
+# Copyright © 2017-2019 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.User.Info do
@@ -18,11 +18,13 @@ defmodule Pleroma.User.Info do
field(:default_scope, :string, default: "public")
field(:blocks, {:array, :string}, default: [])
field(:domain_blocks, {:array, :string}, default: [])
+ field(:mutes, {:array, :string}, default: [])
field(:deactivated, :boolean, default: false)
field(:no_rich_text, :boolean, default: false)
field(:ap_enabled, :boolean, default: false)
field(:is_moderator, :boolean, default: false)
field(:is_admin, :boolean, default: false)
+ field(:show_role, :boolean, default: true)
field(:keys, :string, default: nil)
field(:settings, :map, default: nil)
field(:magic_key, :string, default: nil)
@@ -30,7 +32,10 @@ defmodule Pleroma.User.Info do
field(:topic, :string, default: nil)
field(:hub, :string, default: nil)
field(:salmon, :string, default: nil)
- field(:hide_network, :boolean, default: false)
+ field(:hide_followers, :boolean, default: false)
+ field(:hide_follows, :boolean, default: false)
+ field(:pinned_activities, {:array, :string}, default: [])
+ field(:flavour, :string, default: nil)
# Found in the wild
# ap_id -> Where is this used?
@@ -41,8 +46,6 @@ defmodule Pleroma.User.Info do
# subject _> Where is this used?
end
- def superuser?(info), do: info.is_admin || info.is_moderator
-
def set_activation_status(info, deactivated) do
params = %{deactivated: deactivated}
@@ -71,6 +74,14 @@ defmodule Pleroma.User.Info do
|> validate_required([:follower_count])
end
+ def set_mutes(info, mutes) do
+ params = %{mutes: mutes}
+
+ info
+ |> cast(params, [:mutes])
+ |> validate_required([:mutes])
+ end
+
def set_blocks(info, blocks) do
params = %{blocks: blocks}
@@ -79,6 +90,14 @@ defmodule Pleroma.User.Info do
|> validate_required([:blocks])
end
+ def add_to_mutes(info, muted) do
+ set_mutes(info, Enum.uniq([muted | info.mutes]))
+ end
+
+ def remove_from_mutes(info, muted) do
+ set_mutes(info, List.delete(info.mutes, muted))
+ end
+
def add_to_block(info, blocked) do
set_blocks(info, Enum.uniq([blocked | info.blocks]))
end
@@ -144,8 +163,10 @@ defmodule Pleroma.User.Info do
:no_rich_text,
:default_scope,
:banner,
- :hide_network,
- :background
+ :hide_follows,
+ :hide_followers,
+ :background,
+ :show_role
])
end
@@ -183,6 +204,14 @@ defmodule Pleroma.User.Info do
|> validate_required([:settings])
end
+ def mastodon_flavour_update(info, flavour) do
+ params = %{flavour: flavour}
+
+ info
+ |> cast(params, [:flavour])
+ |> validate_required([:flavour])
+ end
+
def set_source_data(info, source_data) do
params = %{source_data: source_data}
@@ -195,7 +224,30 @@ defmodule Pleroma.User.Info do
info
|> cast(params, [
:is_moderator,
- :is_admin
+ :is_admin,
+ :show_role
])
end
+
+ def add_pinnned_activity(info, %Pleroma.Activity{id: id}) do
+ if id not in info.pinned_activities do
+ max_pinned_statuses = Pleroma.Config.get([:instance, :max_pinned_statuses], 0)
+ params = %{pinned_activities: info.pinned_activities ++ [id]}
+
+ info
+ |> cast(params, [:pinned_activities])
+ |> validate_length(:pinned_activities,
+ max: max_pinned_statuses,
+ message: "You have already pinned the maximum number of statuses"
+ )
+ else
+ change(info)
+ end
+ end
+
+ def remove_pinnned_activity(info, %Pleroma.Activity{id: id}) do
+ params = %{pinned_activities: List.delete(info.pinned_activities, id)}
+
+ cast(info, params, [:pinned_activities])
+ end
end