9972cb9880d590acb293903a595a346e93e9ac8b
[akkoma] / lib / mix / tasks / pleroma / email.ex
1 defmodule Mix.Tasks.Pleroma.Email do
2 use Mix.Task
3 import Mix.Pleroma
4
5 @shortdoc "Email administrative tasks"
6 @moduledoc File.read!("docs/administration/CLI_tasks/email.md")
7
8 def run(["test" | args]) do
9 start_pleroma()
10
11 {options, [], []} =
12 OptionParser.parse(
13 args,
14 strict: [
15 to: :string
16 ]
17 )
18
19 email = Pleroma.Emails.AdminEmail.test_email(options[:to])
20 {:ok, _} = Pleroma.Emails.Mailer.deliver(email)
21
22 shell_info("Test email has been sent to #{inspect(email.to)} from #{inspect(email.from)}")
23 end
24
25 def run(["resend_confirmation_emails"]) do
26 start_pleroma()
27
28 shell_info("Sending emails to all unconfirmed users")
29
30 Pleroma.User.Query.build(%{
31 local: true,
32 deactivated: false,
33 confirmation_pending: true,
34 invisible: false
35 })
36 |> Pleroma.Repo.chunk_stream(500)
37 |> Stream.each(&Pleroma.User.try_send_confirmation_email(&1))
38 |> Stream.run()
39 end
40 end