mastodon api: allow setting an account locked or not
authorWilliam Pitcock <nenolod@dereferenced.org>
Sun, 27 May 2018 10:03:53 +0000 (10:03 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Mon, 11 Jun 2018 22:15:53 +0000 (22:15 +0000)
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex

index cae81c43d6ab8757b1646f522ff1ed0aea429d62..caff4ad86b89f0484148dd8f40b5375f88fa4807 100644 (file)
@@ -72,6 +72,20 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController 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