From 57c71f846880083d8a78247f433713963c284ab9 Mon Sep 17 00:00:00 2001 From: Rin Toshaka Date: Sun, 2 Dec 2018 20:26:15 +0100 Subject: [PATCH] Move generate_invite to user.ex --- lib/mix/tasks/pleroma/gen_invite.ex | 24 ------------------------ lib/mix/tasks/pleroma/instance.ex | 3 ++- lib/mix/tasks/pleroma/user.ex | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 25 deletions(-) delete mode 100644 lib/mix/tasks/pleroma/gen_invite.ex diff --git a/lib/mix/tasks/pleroma/gen_invite.ex b/lib/mix/tasks/pleroma/gen_invite.ex deleted file mode 100644 index 0aa028f1e..000000000 --- a/lib/mix/tasks/pleroma/gen_invite.ex +++ /dev/null @@ -1,24 +0,0 @@ -defmodule Mix.Tasks.Pleroma.Gen.Invite do - use Mix.Task - - @shortdoc "Generates a user invite token" - def run([]) do - Mix.Task.run("app.start") - - with {:ok, token} <- Pleroma.UserInviteToken.create_token() do - Mix.shell().info("Generated user invite token") - - url = - Pleroma.Web.Router.Helpers.redirect_url( - Pleroma.Web.Endpoint, - :registration_page, - token.token - ) - - IO.puts("URL: #{url}") - else - _ -> - Mix.shell().error("Could not create invite token.") - end - end -end diff --git a/lib/mix/tasks/pleroma/instance.ex b/lib/mix/tasks/pleroma/instance.ex index b3e0f99df..05653c238 100644 --- a/lib/mix/tasks/pleroma/instance.ex +++ b/lib/mix/tasks/pleroma/instance.ex @@ -6,7 +6,7 @@ defmodule Mix.Tasks.Pleroma.Instance do @moduledoc """ Manages Pleroma instance. - ## Generate a new instance. + ## Generate a new instance config. mix pleroma.instance new [OPTION...] @@ -145,6 +145,7 @@ def run(["new" | rest]) do end end + defp escape_sh_path(path) do ~S(') <> String.replace(path, ~S('), ~S(\')) <> ~S(') end diff --git a/lib/mix/tasks/pleroma/user.ex b/lib/mix/tasks/pleroma/user.ex index d7e172994..c23c5cdf3 100644 --- a/lib/mix/tasks/pleroma/user.ex +++ b/lib/mix/tasks/pleroma/user.ex @@ -16,6 +16,10 @@ defmodule Mix.Tasks.Pleroma.User do - `--password PASSWORD` - the user's password - `--moderator`/`--no-moderator` - whether the user is a moderator - `--admin`/`--no-admin` - whether the user is an admin + + ## Generate an invite link. + + mix pleroma.user invite ## Delete the user's account. @@ -255,6 +259,26 @@ defp set_admin(nickname, value) do end end + def run(["invite"]) do + Mix.Task.run("app.start") + + with {:ok, token} <- Pleroma.UserInviteToken.create_token() do + Mix.shell().info("Generated user invite token") + + url = + Pleroma.Web.Router.Helpers.redirect_url( + Pleroma.Web.Endpoint, + :registration_page, + token.token + ) + + IO.puts(url) + else + _ -> + Mix.shell().error("Could not create invite token.") + end + + end defp set_locked(nickname, value) do Mix.Ecto.ensure_started(Repo, [])