From ba6e3eba33f16bdd2fede086d5fb5c86201cb57b Mon Sep 17 00:00:00 2001 From: Jorty Date: Thu, 23 Aug 2018 12:37:20 -0400 Subject: [PATCH] Move invite task to pleroma namespace Some other minor changes were made to make it consistent with the behavior of other tasks both within Pleroma and the conventions set by dependencies such as Phoenix. Namely, the task is named `gen.invite` and `IO.puts` has been replaced with references to `Mix.shell()` where appropriate. --- lib/mix/tasks/generate_invite_token.ex | 25 ------------------------- lib/mix/tasks/pleroma/gen_invite.ex | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 25 deletions(-) delete mode 100644 lib/mix/tasks/generate_invite_token.ex create mode 100644 lib/mix/tasks/pleroma/gen_invite.ex diff --git a/lib/mix/tasks/generate_invite_token.ex b/lib/mix/tasks/generate_invite_token.ex deleted file mode 100644 index c4daa9a6c..000000000 --- a/lib/mix/tasks/generate_invite_token.ex +++ /dev/null @@ -1,25 +0,0 @@ -defmodule Mix.Tasks.GenerateInviteToken do - use Mix.Task - - @shortdoc "Generate invite token for user" - def run([]) do - Mix.Task.run("app.start") - - with {:ok, token} <- Pleroma.UserInviteToken.create_token() do - IO.puts("Generated user invite token") - - IO.puts( - "Url: #{ - Pleroma.Web.Router.Helpers.redirect_url( - Pleroma.Web.Endpoint, - :registration_page, - token.token - ) - }" - ) - else - _ -> - IO.puts("Error creating token") - end - end -end diff --git a/lib/mix/tasks/pleroma/gen_invite.ex b/lib/mix/tasks/pleroma/gen_invite.ex new file mode 100644 index 000000000..0aa028f1e --- /dev/null +++ b/lib/mix/tasks/pleroma/gen_invite.ex @@ -0,0 +1,24 @@ +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