aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2019-05-31 14:27:15 +0200
committerlain <lain@soykaf.club>2019-05-31 14:27:15 +0200
commiteb2963bc43f2cb195c2f19e6081c3faa6375fe4e (patch)
treed11e8252ac0db7847b651ea2552fa226ca2b87fd /lib
parent3cc00fd2e9924e2c05bda3eb198881046e85f709 (diff)
downloadpleroma-eb2963bc43f2cb195c2f19e6081c3faa6375fe4e.tar.gz
User: Add settings store to Info, AccountView
This is to provide a generic frontend settings storage mechanism for all kinds of frontends.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/user/info.ex1
-rw-r--r--lib/pleroma/web/mastodon_api/views/account_view.ex10
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex
index 6397e2737..e6623160d 100644
--- a/lib/pleroma/user/info.ex
+++ b/lib/pleroma/user/info.ex
@@ -45,6 +45,7 @@ defmodule Pleroma.User.Info do
field(:flavour, :string, default: nil)
field(:mascot, :map, default: nil)
field(:emoji, {:array, :map}, default: [])
+ field(:pleroma_settings_store, :map, default: %{})
field(:notification_settings, :map,
default: %{"remote" => true, "local" => true, "followers" => true, "follows" => true}
diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex
index b82d3319b..04d485340 100644
--- a/lib/pleroma/web/mastodon_api/views/account_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/account_view.ex
@@ -130,6 +130,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|> maybe_put_role(user, opts[:for])
|> maybe_put_settings(user, opts[:for], user_info)
|> maybe_put_notification_settings(user, opts[:for])
+ |> maybe_put_settings_store(user, opts[:for], opts)
end
defp username_from_nickname(string) when is_binary(string) do
@@ -152,6 +153,15 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
defp maybe_put_settings(data, _, _, _), do: data
+ defp maybe_put_settings_store(data, %User{info: info, id: id}, %User{id: id}, %{
+ with_pleroma_settings: true
+ }) do
+ data
+ |> Kernel.put_in([:pleroma, :settings], info.pleroma_settings_store)
+ end
+
+ defp maybe_put_settings_store(data, _, _, _), do: data
+
defp maybe_put_role(data, %User{info: %{show_role: true}} = user, _) do
data
|> Kernel.put_in([:pleroma, :is_admin], user.info.is_admin)