2020-10-12 17:00:50 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
2021-01-13 06:49:20 +00:00
|
|
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
2020-10-12 17:00:50 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
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
|
2020-09-24 21:47:34 +00:00
|
|
|
start_pleroma()
|
2020-01-20 12:23:21 +00:00
|
|
|
|
|
|
|
{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()
|
|
|
|
|
2020-09-24 23:35:20 +00:00
|
|
|
shell_info("Sending emails to all unconfirmed users")
|
|
|
|
|
2020-09-08 21:39:08 +00:00
|
|
|
Pleroma.User.Query.build(%{
|
|
|
|
local: true,
|
|
|
|
deactivated: false,
|
|
|
|
confirmation_pending: true,
|
|
|
|
invisible: false
|
|
|
|
})
|
2020-09-24 23:23:47 +00:00
|
|
|
|> Pleroma.Repo.chunk_stream(500)
|
2020-09-23 17:32:47 +00:00
|
|
|
|> 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
|