forked from YokaiRick/akkoma
Merge branch 'fix/persisted-mastofe-settings' into 'develop'
MastoAPI: Persist frontend timelines and settings. Closes #113 See merge request pleroma/pleroma!98
This commit is contained in:
commit
9a2d3705c6
2 changed files with 19 additions and 1 deletions
|
@ -604,7 +604,7 @@ def index(%{assigns: %{user: user}} = conn, _params) do
|
|||
"video\/mp4"
|
||||
]
|
||||
},
|
||||
settings: %{
|
||||
settings: Map.get(user.info, "settings") || %{
|
||||
onboarded: true,
|
||||
home: %{
|
||||
shows: %{
|
||||
|
@ -649,6 +649,18 @@ def index(%{assigns: %{user: user}} = conn, _params) 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})
|
||||
|
|
|
@ -120,6 +120,12 @@ def user_fetcher(username) 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)
|
||||
|
|
Loading…
Reference in a new issue