youjo-be/lib/mix/tasks/pleroma/email.ex

45 lines
1.1 KiB
Elixir
Raw Normal View History

2020-10-12 19:00:50 +02:00
# Pleroma: A lightweight social networking server
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
2020-10-12 19:00:50 +02:00
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Mix.Tasks.Pleroma.Email do
use Mix.Task
import Mix.Pleroma
@shortdoc "Email administrative tasks"
@moduledoc File.read!("docs/docs/administration/CLI_tasks/email.md")
def run(["test" | args]) do
2020-09-24 23:47:34 +02:00
start_pleroma()
{options, [], []} =
OptionParser.parse(
args,
strict: [
to: :string
]
)
email = Pleroma.Emails.AdminEmail.test_email(options[:to])
{:ok, _} = Pleroma.Emails.Mailer.deliver(email)
shell_info("Test email has been sent to #{inspect(email.to)} from #{inspect(email.from)}")
end
def run(["resend_confirmation_emails"]) do
start_pleroma()
2020-09-25 01:35:20 +02:00
shell_info("Sending emails to all unconfirmed users")
Pleroma.User.Query.build(%{
local: true,
is_active: true,
is_confirmed: false,
invisible: false
})
|> Pleroma.Repo.chunk_stream(500)
2021-02-04 21:33:49 +01:00
|> Stream.each(&Pleroma.User.maybe_send_confirmation_email(&1))
|> Stream.run()
end
end