From d69af7f74290a67c9201782b7d4bafa29b6e0bd8 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Tue, 30 Jun 2020 11:50:53 -0500 Subject: [PATCH] Rename user.settings column This is used exclusively by MastoFE/GlitchFE now --- lib/pleroma/user.ex | 6 +++--- lib/pleroma/web/views/masto_fe_view.ex | 2 +- .../20200630162024_rename_user_settings_col.exs | 11 +++++++++++ test/web/masto_fe_controller_test.exs | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 priv/repo/migrations/20200630162024_rename_user_settings_col.exs diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 9d5c61e79..8a54546d6 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -115,7 +115,7 @@ defmodule Pleroma.User do field(:is_moderator, :boolean, default: false) field(:is_admin, :boolean, default: false) field(:show_role, :boolean, default: true) - field(:settings, :map, default: nil) + field(:mastofe_settings, :map, default: nil) field(:uri, ObjectValidators.Uri, default: nil) field(:hide_followers_count, :boolean, default: false) field(:hide_follows_count, :boolean, default: false) @@ -2118,8 +2118,8 @@ defmodule Pleroma.User do def mastodon_settings_update(user, settings) do user - |> cast(%{settings: settings}, [:settings]) - |> validate_required([:settings]) + |> cast(%{mastofe_settings: settings}, [:mastofe_settings]) + |> validate_required([:mastofe_settings]) |> update_and_set_cache() end diff --git a/lib/pleroma/web/views/masto_fe_view.ex b/lib/pleroma/web/views/masto_fe_view.ex index c3096006e..f739dacb6 100644 --- a/lib/pleroma/web/views/masto_fe_view.ex +++ b/lib/pleroma/web/views/masto_fe_view.ex @@ -86,7 +86,7 @@ defmodule Pleroma.Web.MastoFEView do "video\/mp4" ] }, - settings: user.settings || @default_settings, + settings: user.mastofe_settings || @default_settings, push_subscription: nil, accounts: %{user.id => render(AccountView, "show.json", user: user, for: user)}, custom_emojis: render(CustomEmojiView, "index.json", custom_emojis: custom_emojis), diff --git a/priv/repo/migrations/20200630162024_rename_user_settings_col.exs b/priv/repo/migrations/20200630162024_rename_user_settings_col.exs new file mode 100644 index 000000000..2355eb681 --- /dev/null +++ b/priv/repo/migrations/20200630162024_rename_user_settings_col.exs @@ -0,0 +1,11 @@ +defmodule Pleroma.Repo.Migrations.RenameUserSettingsCol do + use Ecto.Migration + + def up do + rename(table(:users), :settings, to: :mastofe_settings) + end + + def down do + rename(table(:users), :mastofe_settings, to: :settings) + end +end diff --git a/test/web/masto_fe_controller_test.exs b/test/web/masto_fe_controller_test.exs index 1d107d56c..f3b54b5f2 100644 --- a/test/web/masto_fe_controller_test.exs +++ b/test/web/masto_fe_controller_test.exs @@ -24,7 +24,7 @@ defmodule Pleroma.Web.MastodonAPI.MastoFEController do assert _result = json_response(conn, 200) user = User.get_cached_by_ap_id(user.ap_id) - assert user.settings == %{"programming" => "socks"} + assert user.mastofe_settings == %{"programming" => "socks"} end describe "index/2 redirections" do