Merge branch 'develop' into 'develop'
[akkoma] / lib / pleroma / web / mastodon_api / mastodon_api_controller.ex
index 4db7cd60f0e56530ad4f46e64f31bc02a5cf8733..726807f0aa3590cef98329fa7b3807dcc1a1536f 100644 (file)
@@ -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
 
@@ -1061,7 +1063,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
     response = %{
       id: to_string(id),
       type: mastodon_type,
-      created_at: CommonAPI.Utils.to_masto_date(activity.inserted_at),
+      created_at: CommonAPI.Utils.to_masto_date(created_at),
       account: AccountView.render("account.json", %{user: actor, for: user})
     }