mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-23 06:58:58 +00:00
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.
This commit is contained in:
parent
76ed9ca1e9
commit
ba6e3eba33
|
@ -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
|
24
lib/mix/tasks/pleroma/gen_invite.ex
Normal file
24
lib/mix/tasks/pleroma/gen_invite.ex
Normal file
|
@ -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
|
Loading…
Reference in a new issue