Add rm_user mix task
authorPhenethylamine <phenethylamine@tutanota.com>
Thu, 12 Apr 2018 06:43:48 +0000 (02:43 -0400)
committerPhenethylamine <phenethylamine@tutanota.com>
Thu, 12 Apr 2018 06:43:48 +0000 (02:43 -0400)
lib/mix/tasks/rm_user.ex [new file with mode: 0644]

diff --git a/lib/mix/tasks/rm_user.ex b/lib/mix/tasks/rm_user.ex
new file mode 100644 (file)
index 0000000..30196d5
--- /dev/null
@@ -0,0 +1,14 @@
+defmodule Mix.Tasks.RmUser do
+  use Mix.Task
+  import Mix.Ecto
+  alias Pleroma.{Repo, User}
+
+  @shortdoc "Permanently delete a user"
+  def run([nickname]) do
+    ensure_started(Repo, [])
+
+    with %User{local: true} = user <- User.get_by_nickname(nickname) do
+      Repo.delete!(user)
+    end
+  end
+end