From: Jorty Date: Thu, 23 Aug 2018 16:37:20 +0000 (-0400) Subject: Move invite task to pleroma namespace X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=ba6e3eba33f16bdd2fede086d5fb5c86201cb57b;p=akkoma 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. --- 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