From a2c4a5a75bc22653553fdf2f3ec25e2c9dd7c66a Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sun, 27 May 2018 10:03:53 +0000 Subject: [PATCH] mastodon api: allow setting an account locked or not --- .../web/mastodon_api/mastodon_api_controller.ex | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index cae81c43d..caff4ad86 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -72,6 +72,20 @@ def update_credentials(%{assigns: %{user: user}} = conn, params) do user 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), {:ok, user} <- User.update_and_set_cache(changeset) do if original_user != user do