diff options
author | Maksim Pechnikov <parallel588@gmail.com> | 2019-12-09 19:41:43 +0300 |
---|---|---|
committer | Maksim Pechnikov <parallel588@gmail.com> | 2019-12-09 19:41:43 +0300 |
commit | 2b821036c4bd84cee51c9fcace5a4b3764c3bba1 (patch) | |
tree | 811d75ef4b0442f3f2102d873fab4e10c777e7f1 /lib/pleroma/user.ex | |
parent | 5876a9cb79e53f932d63e457610852031669a222 (diff) | |
parent | 0d2c13a119302d0d217a7cb61c28a01c620b1b61 (diff) | |
download | pleroma-2b821036c4bd84cee51c9fcace5a4b3764c3bba1.tar.gz |
Merge branch 'develop' into issue/1383
Diffstat (limited to 'lib/pleroma/user.ex')
-rw-r--r-- | lib/pleroma/user.ex | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index b7f50e5ac..e2afc6de8 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -129,13 +129,10 @@ defmodule Pleroma.User do field(:skip_thread_containment, :boolean, default: false) field(:also_known_as, {:array, :string}, default: []) - field(:notification_settings, :map, - default: %{ - "followers" => true, - "follows" => true, - "non_follows" => true, - "non_followers" => true - } + embeds_one( + :notification_settings, + Pleroma.User.NotificationSetting, + on_replace: :update ) has_many(:notifications, Notification) @@ -1221,20 +1218,9 @@ defmodule Pleroma.User do end def update_notification_settings(%User{} = user, settings) do - settings = - settings - |> Enum.map(fn {k, v} -> {k, v in [true, "true", "True", "1"]} end) - |> Map.new() - - notification_settings = - user.notification_settings - |> Map.merge(settings) - |> Map.take(["followers", "follows", "non_follows", "non_followers"]) - - params = %{notification_settings: notification_settings} - user - |> cast(params, [:notification_settings]) + |> cast(%{notification_settings: settings}, []) + |> cast_embed(:notification_settings) |> validate_required([:notification_settings]) |> update_and_set_cache() end |