diff options
author | eal <eal@waifu.club> | 2018-12-16 13:15:34 +0200 |
---|---|---|
committer | eal <eal@waifu.club> | 2018-12-16 13:15:34 +0200 |
commit | 4c783e35c09c74097257ce56fde74025db0024c6 (patch) | |
tree | d4f4553430fdddd7369445c82d7968b05a2505f4 /lib | |
parent | 2592b3c81a5af20536c3cc9709e3971d6cfb1e68 (diff) | |
download | pleroma-4c783e35c09c74097257ce56fde74025db0024c6.tar.gz |
Mastodon API: Fix PUT /api/web/settings
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/user/info.ex | 5 | ||||
-rw-r--r-- | lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 8 |
2 files changed, 9 insertions, 4 deletions
diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex index d81b45b8d..a3785447c 100644 --- a/lib/pleroma/user/info.ex +++ b/lib/pleroma/user/info.ex @@ -149,9 +149,12 @@ defmodule Pleroma.User.Info do ]) end - def mastodon_settings_update(info, params) do + def mastodon_settings_update(info, settings) do + params = %{settings: settings} + info |> cast(params, [:settings]) + |> validate_required([:settings]) end def set_source_data(info, source_data) do diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 5c8602322..a46e1878f 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -929,7 +929,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do ] }, settings: - Map.get(user.info, :settings) || + user.info.settings || %{ onboarded: true, home: %{ @@ -978,13 +978,15 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do def put_settings(%{assigns: %{user: user}} = conn, %{"data" => settings} = _params) do info_cng = User.Info.mastodon_settings_update(user.info, settings) - with changeset <- User.update_changeset(user), + with changeset <- Ecto.Changeset.change(user), changeset <- Ecto.Changeset.put_embed(changeset, :info, info_cng), {:ok, _user} <- User.update_and_set_cache(changeset) do json(conn, %{}) else e -> - json(conn, %{error: inspect(e)}) + conn + |> put_resp_content_type("application/json") + |> send_resp(500, Jason.encode!(%{"error" => inspect(e)})) end end |