diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index ed1db04c9af8540c5a0eb90f0fcb3354283b3a92..29835769e315a1de325f956ff7627fc97b4c9f44 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -130,6 +130,7 @@ defmodule Pleroma.User do field(:pleroma_settings_store, :map, default: %{}) field(:fields, {:array, :map}, default: []) field(:raw_fields, {:array, :map}, default: []) + field(:admin_data, :map, default: %{}) field(:discoverable, :boolean, default: false) field(:invisible, :boolean, default: false) field(:allow_following_move, :boolean, default: true) diff --git a/lib/pleroma/web/api_spec/schemas/account.ex b/lib/pleroma/web/api_spec/schemas/account.ex index ca79f0747861b93bb63e5d40022878369ffad247..09c6863ee472dffa96d42eb45db11072a6b4a606 100644 --- a/lib/pleroma/web/api_spec/schemas/account.ex +++ b/lib/pleroma/web/api_spec/schemas/account.ex @@ -106,6 +106,10 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do format: :uri, nullable: true, description: "Favicon image of the user's instance" + }, + admin_data: %Schema{ + type: :map, + description: "Custom data set by the server admin" } } }, diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex index 864c0417f14a2694ac9cb0583d118ceb4d4806c4..9b3c74e5a005424590a47c08c33392313d22e0c2 100644 --- a/lib/pleroma/web/mastodon_api/views/account_view.ex +++ b/lib/pleroma/web/mastodon_api/views/account_view.ex @@ -278,7 +278,8 @@ defp do_render("show.json", %{user: user} = opts) do skip_thread_containment: user.skip_thread_containment, background_image: image_url(user.background) |> MediaProxy.url(), accepts_chat_messages: user.accepts_chat_messages, - favicon: favicon + favicon: favicon, + admin_data: user.admin_data } } |> maybe_put_role(user, opts[:for]) diff --git a/priv/repo/migrations/20200728212102_add_admin_data_to_users.exs b/priv/repo/migrations/20200728212102_add_admin_data_to_users.exs new file mode 100644 index 0000000000000000000000000000000000000000..512840a39fcdad525cf597ef8d53697e8fec57da --- /dev/null +++ b/priv/repo/migrations/20200728212102_add_admin_data_to_users.exs @@ -0,0 +1,9 @@ +defmodule Pleroma.Repo.Migrations.AddAdminDataToUsers do + use Ecto.Migration + + def change do + alter table(:users) do + add(:admin_data, :map, default: %{}) + end + end +end diff --git a/test/web/mastodon_api/views/account_view_test.exs b/test/web/mastodon_api/views/account_view_test.exs index 8f37efa3c3e2b8df5fa13bfa7955ac5f898fbb3c..60c232781ff7f7ede8d74ac1607f04c88f6f5221 100644 --- a/test/web/mastodon_api/views/account_view_test.exs +++ b/test/web/mastodon_api/views/account_view_test.exs @@ -37,7 +37,8 @@ test "Represent a user account" do "<script src=\"invalid-html\"></script><span>valid html</span>. a<br>b<br/>c<br >d<br />f '&<>\"", inserted_at: ~N[2017-08-15 15:47:06.597036], emoji: %{"karjalanpiirakka" => "/file.png"}, - raw_bio: "valid html. a\nb\nc\nd\nf '&<>\"" + raw_bio: "valid html. a\nb\nc\nd\nf '&<>\"", + admin_data: %{"is_verifed" => true} }) expected = %{ @@ -91,7 +92,8 @@ test "Represent a user account" do hide_follows_count: false, relationship: %{}, skip_thread_containment: false, - accepts_chat_messages: nil + accepts_chat_messages: nil, + admin_data: %{"is_verifed" => true} } } @@ -186,7 +188,8 @@ test "Represent a Service(bot) account" do hide_follows_count: false, relationship: %{}, skip_thread_containment: false, - accepts_chat_messages: nil + accepts_chat_messages: nil, + admin_data: %{} } }