2020-01-20 12:23:21 +00:00
|
|
|
defmodule Mix.Tasks.Pleroma.Email do
|
|
|
|
use Mix.Task
|
2020-02-09 00:27:29 +00:00
|
|
|
import Mix.Pleroma
|
2020-01-20 12:23:21 +00:00
|
|
|
|
2020-09-08 21:39:08 +00:00
|
|
|
@shortdoc "Email administrative tasks"
|
2020-01-20 12:23:21 +00:00
|
|
|
@moduledoc File.read!("docs/administration/CLI_tasks/email.md")
|
|
|
|
|
|
|
|
def run(["test" | args]) do
|
|
|
|
Mix.Pleroma.start_pleroma()
|
|
|
|
|
|
|
|
{options, [], []} =
|
|
|
|
OptionParser.parse(
|
|
|
|
args,
|
|
|
|
strict: [
|
|
|
|
to: :string
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
email = Pleroma.Emails.AdminEmail.test_email(options[:to])
|
|
|
|
{:ok, _} = Pleroma.Emails.Mailer.deliver(email)
|
|
|
|
|
2020-02-09 00:27:29 +00:00
|
|
|
shell_info("Test email has been sent to #{inspect(email.to)} from #{inspect(email.from)}")
|
2020-01-20 12:23:21 +00:00
|
|
|
end
|
2020-09-08 21:39:08 +00:00
|
|
|
|
|
|
|
def run(["resend_confirmation_emails"]) do
|
|
|
|
start_pleroma()
|
|
|
|
|
|
|
|
Pleroma.User.Query.build(%{
|
|
|
|
local: true,
|
|
|
|
deactivated: false,
|
|
|
|
confirmation_pending: true,
|
|
|
|
invisible: false
|
|
|
|
})
|
2020-09-23 17:32:47 +00:00
|
|
|
|> Pleroma.Repo.chunk_stream(500, :batches)
|
|
|
|
|> Stream.each(&Pleroma.User.try_send_confirmation_email(&1))
|
2020-09-08 21:39:08 +00:00
|
|
|
|> Stream.run()
|
|
|
|
end
|
2020-01-20 12:23:21 +00:00
|
|
|
end
|