From a40ba3ba57158401583c5f80aaa78d80b4ca319f Mon Sep 17 00:00:00 2001 From: link0ff Date: Wed, 12 Dec 2018 22:30:16 +0200 Subject: [PATCH 1/2] Fix toggle_activated in mix task User --- lib/mix/tasks/pleroma/user.ex | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/mix/tasks/pleroma/user.ex b/lib/mix/tasks/pleroma/user.ex index 2675b021d..bcc3b9e50 100644 --- a/lib/mix/tasks/pleroma/user.ex +++ b/lib/mix/tasks/pleroma/user.ex @@ -142,8 +142,11 @@ def run(["toggle_activated", nickname]) do Common.start_pleroma() with %User{} = user <- User.get_by_nickname(nickname) do - User.deactivate(user, !user.info["deactivated"]) - Mix.shell().info("Activation status of #{nickname}: #{user.info["deactivated"]}") + {:ok, user} = User.deactivate(user, !user.info.deactivated) + + Mix.shell().info( + "Activation status of #{nickname}: #{if(user.info.deactivated, do: "de", else: "")}activated" + ) else _ -> Mix.shell().error("No user #{nickname}") From 51dd294c486474d453dbbd508995505017597bc2 Mon Sep 17 00:00:00 2001 From: link0ff Date: Wed, 12 Dec 2018 22:32:32 +0200 Subject: [PATCH 2/2] Allow to set both admin and moderator at the same time in mix task User --- lib/mix/tasks/pleroma/user.ex | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/lib/mix/tasks/pleroma/user.ex b/lib/mix/tasks/pleroma/user.ex index bcc3b9e50..fe6e6935f 100644 --- a/lib/mix/tasks/pleroma/user.ex +++ b/lib/mix/tasks/pleroma/user.ex @@ -218,20 +218,23 @@ def run(["set", nickname | rest]) do ) with %User{local: true} = user <- User.get_by_nickname(nickname) do - case Keyword.get(options, :moderator) do - nil -> nil - value -> set_moderator(user, value) - end + user = + case Keyword.get(options, :moderator) do + nil -> user + value -> set_moderator(user, value) + end - case Keyword.get(options, :locked) do - nil -> nil - value -> set_locked(user, value) - end + user = + case Keyword.get(options, :locked) do + nil -> user + value -> set_locked(user, value) + end - case Keyword.get(options, :admin) do - nil -> nil - value -> set_admin(user, value) - end + _user = + case Keyword.get(options, :admin) do + nil -> user + value -> set_admin(user, value) + end else _ -> Mix.shell().error("No local user #{nickname}") @@ -268,6 +271,7 @@ defp set_moderator(user, value) do {:ok, user} = User.update_and_set_cache(user_cng) Mix.shell().info("Moderator status of #{user.nickname}: #{user.info.is_moderator}") + user end defp set_admin(user, value) do @@ -279,7 +283,8 @@ defp set_admin(user, value) do {:ok, user} = User.update_and_set_cache(user_cng) - Mix.shell().info("Admin status of #{user.nickname}: #{user.info.is_moderator}") + Mix.shell().info("Admin status of #{user.nickname}: #{user.info.is_admin}") + user end defp set_locked(user, value) do @@ -292,5 +297,6 @@ defp set_locked(user, value) do {:ok, user} = User.update_and_set_cache(user_cng) Mix.shell().info("Locked status of #{user.nickname}: #{user.info.locked}") + user end end