aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJorty <jorty@jort.space>2018-08-23 12:37:20 -0400
committerJorty <jorty@jort.space>2018-08-23 12:46:13 -0400
commitba6e3eba33f16bdd2fede086d5fb5c86201cb57b (patch)
tree33dcac70751de5f8eb35966b844fce2c279ed79b /lib
parent76ed9ca1e93dfada63f50d6ba22491ef8d5d253c (diff)
downloadpleroma-ba6e3eba33f16bdd2fede086d5fb5c86201cb57b.tar.gz
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/mix/tasks/generate_invite_token.ex25
-rw-r--r--lib/mix/tasks/pleroma/gen_invite.ex24
2 files changed, 24 insertions, 25 deletions
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