fix api/v1/accounts/update_credentials
[akkoma] / lib / pleroma / web / mastodon_api / controllers / account_controller.ex
index 2dd0252ccb9c77ddf1c2a6f25962dbfba9e349f0..75512442de1c352cda4aeb60fc075566aa8cfb6c 100644 (file)
@@ -10,7 +10,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
       add_link_headers: 2,
       truthy_param?: 1,
       assign_account_by_id: 2,
-      with_relationships?: 1,
+      embed_relationships?: 1,
       json_response: 3
     ]
 
@@ -177,6 +177,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
       )
       |> add_if_present(params, :pleroma_settings_store, :pleroma_settings_store)
       |> add_if_present(params, :default_scope, :default_scope)
+      |> add_if_present(params["source"], "privacy", :default_scope)
       |> add_if_present(params, :actor_type, :actor_type)
 
     changeset = User.update_changeset(user, user_params)
@@ -189,7 +190,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
   end
 
   defp add_if_present(map, params, params_field, map_field, value_function \\ &{:ok, &1}) do
-    with true <- Map.has_key?(params, params_field),
+    with true <- is_map(params),
+         true <- Map.has_key?(params, params_field),
          {:ok, new_value} <- value_function.(Map.get(params, params_field)) do
       Map.put(map, map_field, new_value)
     else
@@ -275,7 +277,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
       for: for_user,
       users: followers,
       as: :user,
-      embed_relationships: with_relationships?(params)
+      embed_relationships: embed_relationships?(params)
     )
   end
 
@@ -300,7 +302,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
       for: for_user,
       users: followers,
       as: :user,
-      embed_relationships: with_relationships?(params)
+      embed_relationships: embed_relationships?(params)
     )
   end