### Changed
- **Breaking**: Changed `mix pleroma.user toggle_confirmed` to `mix pleroma.user confirm`
-- **Breaking**: Changed `mix pleroma.user toggle_activated` to `mix pleroma.user activate`
+- **Breaking**: Changed `mix pleroma.user toggle_activated` to `mix pleroma.user activate/deactivate`
- **Breaking**: AdminAPI changed User field `confirmation_pending` to `is_confirmed`
- **Breaking**: AdminAPI changed User field `approval_pending` to `is_approved`
- **Breaking**: AdminAPI changed User field `deactivated` to `is_active`
end
end
+ def run(["activate", nickname]) do
+ start_pleroma()
+
+ with %User{} = user <- User.get_cached_by_nickname(nickname),
+ false <- user.is_active do
+ User.set_activation(user, true)
+ :timer.sleep(500)
+
+ shell_info("Successfully activated #{nickname}")
+ else
+ true ->
+ shell_info("User #{nickname} already activated")
+
+ _ ->
+ shell_error("No user #{nickname}")
+ end
+ end
+
def run(["deactivate", nickname]) do
start_pleroma()
end
end
+ describe "running activate" do
+ test "user is activated" do
+ %{id: id, nickname: nickname} = insert(:user, is_active: true)
+
+ assert :ok = Mix.Tasks.Pleroma.User.run(["activate", nickname])
+ assert_received {:mix_shell, :info, [message]}
+ assert message == "User #{nickname} already activated"
+
+ user = Repo.get(User, id)
+ assert user.is_active
+ end
+
+ test "user is not activated" do
+ %{id: id, nickname: nickname} = insert(:user, is_active: false)
+
+ assert :ok = Mix.Tasks.Pleroma.User.run(["activate", nickname])
+ assert_received {:mix_shell, :info, [message]}
+ assert message == "Successfully activated #{nickname}"
+
+ user = Repo.get(User, id)
+ assert user.is_active
+ end
+
+ test "it prints an error message when user is not exist" do
+ Mix.Tasks.Pleroma.User.run(["activate", "foo"])
+
+ assert_received {:mix_shell, :error, [message]}
+ assert message =~ "No user"
+ end
+ end
+
describe "search" do
test "it returns users matching" do
user = insert(:user)