mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-23 15:05:45 +00:00
Merge branch 'issue/1667' into 'develop'
[#1667] fix api/v1/accounts/update_credentials See merge request pleroma/pleroma!2556
This commit is contained in:
commit
7e3814390e
|
@ -177,6 +177,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
|
||||||
)
|
)
|
||||||
|> add_if_present(params, :pleroma_settings_store, :pleroma_settings_store)
|
|> add_if_present(params, :pleroma_settings_store, :pleroma_settings_store)
|
||||||
|> add_if_present(params, :default_scope, :default_scope)
|
|> add_if_present(params, :default_scope, :default_scope)
|
||||||
|
|> add_if_present(params["source"], "privacy", :default_scope)
|
||||||
|> add_if_present(params, :actor_type, :actor_type)
|
|> add_if_present(params, :actor_type, :actor_type)
|
||||||
|
|
||||||
changeset = User.update_changeset(user, user_params)
|
changeset = User.update_changeset(user, user_params)
|
||||||
|
@ -189,7 +190,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp add_if_present(map, params, params_field, map_field, value_function \\ &{:ok, &1}) do
|
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
|
{:ok, new_value} <- value_function.(Map.get(params, params_field)) do
|
||||||
Map.put(map, map_field, new_value)
|
Map.put(map, map_field, new_value)
|
||||||
else
|
else
|
||||||
|
|
|
@ -112,6 +112,13 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
|
||||||
assert user_data["source"]["privacy"] == "unlisted"
|
assert user_data["source"]["privacy"] == "unlisted"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "updates the user's privacy", %{conn: conn} do
|
||||||
|
conn = patch(conn, "/api/v1/accounts/update_credentials", %{source: %{privacy: "unlisted"}})
|
||||||
|
|
||||||
|
assert user_data = json_response_and_validate_schema(conn, 200)
|
||||||
|
assert user_data["source"]["privacy"] == "unlisted"
|
||||||
|
end
|
||||||
|
|
||||||
test "updates the user's hide_followers status", %{conn: conn} do
|
test "updates the user's hide_followers status", %{conn: conn} do
|
||||||
conn = patch(conn, "/api/v1/accounts/update_credentials", %{hide_followers: "true"})
|
conn = patch(conn, "/api/v1/accounts/update_credentials", %{hide_followers: "true"})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue