mastodon api: allow setting an account locked or not
This commit is contained in:
parent
ad7188fe92
commit
a2c4a5a75b
1 changed files with 14 additions and 0 deletions
|
@ -72,6 +72,20 @@ def update_credentials(%{assigns: %{user: user}} = conn, params) do
|
||||||
user
|
user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
user =
|
||||||
|
if locked = params["locked"] do
|
||||||
|
with locked <- locked == "true",
|
||||||
|
new_info <- Map.put(user.info, "locked", locked),
|
||||||
|
change <- User.info_changeset(user, %{info: new_info}),
|
||||||
|
{:ok, user} <- User.update_and_set_cache(change) do
|
||||||
|
user
|
||||||
|
else
|
||||||
|
_e -> user
|
||||||
|
end
|
||||||
|
else
|
||||||
|
user
|
||||||
|
end
|
||||||
|
|
||||||
with changeset <- User.update_changeset(user, params),
|
with changeset <- User.update_changeset(user, params),
|
||||||
{:ok, user} <- User.update_and_set_cache(changeset) do
|
{:ok, user} <- User.update_and_set_cache(changeset) do
|
||||||
if original_user != user do
|
if original_user != user do
|
||||||
|
|
Loading…
Reference in a new issue