diff options
author | lambda <pleromagit@rogerbraun.net> | 2018-04-08 06:01:06 +0000 |
---|---|---|
committer | lambda <pleromagit@rogerbraun.net> | 2018-04-08 06:01:06 +0000 |
commit | 9a2d3705c69ed4acd97d423013d29f8d5d608f94 (patch) | |
tree | 1c29ea47fcc0f7d869b89ba83f6937606349013a | |
parent | 8f9bcc4ab0b16efa9168f49f6e2cc14bc424d398 (diff) | |
parent | 7c47534970e0a648ded4700fe20c99d6ab15cd5c (diff) | |
download | pleroma-9a2d3705c69ed4acd97d423013d29f8d5d608f94.tar.gz pleroma-9a2d3705c69ed4acd97d423013d29f8d5d608f94.zip |
Merge branch 'fix/persisted-mastofe-settings' into 'develop'
MastoAPI: Persist frontend timelines and settings.
Closes #113
See merge request pleroma/pleroma!98
-rw-r--r-- | lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 14 | ||||
-rw-r--r-- | lib/pleroma/web/router.ex | 6 |
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 6339704a2..97a618186 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -604,7 +604,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do "video\/mp4" ] }, - settings: %{ + settings: Map.get(user.info, "settings") || %{ onboarded: true, home: %{ shows: %{ @@ -649,6 +649,18 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do end end + def put_settings(%{assigns: %{user: user}} = conn, %{"data" => settings} = _params) do + with new_info <- Map.put(user.info, "settings", settings), + change <- User.info_changeset(user, %{info: new_info}), + {:ok, _user} <- User.update_and_set_cache(change) do + conn + |> json(%{}) + else e -> + conn + |> json(%{error: inspect(e)}) + end + end + def login(conn, _) do conn |> render(MastodonView, "login.html", %{error: false}) diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index 5f27f3caa..a33d03fc9 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -120,6 +120,12 @@ defmodule Pleroma.Web.Router do post("/media", MastodonAPIController, :upload) end + scope "/api/web", Pleroma.Web.MastodonAPI do + pipe_through(:authenticated_api) + + put("/settings", MastodonAPIController, :put_settings) + end + scope "/api/v1", Pleroma.Web.MastodonAPI do pipe_through(:api) get("/instance", MastodonAPIController, :masto_instance) |