summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api_controller.ex17
-rw-r--r--lib/pleroma/web/router.ex7
2 files changed, 22 insertions, 2 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..b00f1e15c 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
@@ -102,13 +102,14 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
end
@instance Application.get_env(:pleroma, :instance)
+ @mastodon_api_level "2.3.3"
def masto_instance(conn, _params) do
response = %{
uri: Web.base_url(),
title: Keyword.get(@instance, :name),
description: "A Pleroma instance, an alternative fediverse server",
- version: Keyword.get(@instance, :version),
+ version: "#{@mastodon_api_level} (compatible; #{Keyword.get(@instance, :version)})",
email: Keyword.get(@instance, :email),
urls: %{
streaming_api: String.replace(Web.base_url(), ["http", "https"], "wss")
@@ -604,7 +605,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
"video\/mp4"
]
},
- settings: %{
+ settings: Map.get(user.info, "settings") || %{
onboarded: true,
home: %{
shows: %{
@@ -649,6 +650,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..8ee27e63c 100644
--- a/lib/pleroma/web/router.ex
+++ b/lib/pleroma/web/router.ex
@@ -100,6 +100,7 @@ defmodule Pleroma.Web.Router do
get("/domain_blocks", MastodonAPIController, :empty_array)
get("/follow_requests", MastodonAPIController, :empty_array)
get("/mutes", MastodonAPIController, :empty_array)
+ get("/lists", MastodonAPIController, :empty_array)
get("/timelines/home", MastodonAPIController, :home_timeline)
@@ -120,6 +121,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)