2020-10-12 17:00:50 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
2023-01-02 20:38:50 +00:00
|
|
|
# Copyright © 2017-2022 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,
|
2020-10-12 22:42:27 +00:00
|
|
|
is_active: true,
|
2020-10-13 19:29:34 +00:00
|
|
|
is_confirmed: false,
|
2020-09-08 21:39:08 +00:00
|
|
|
invisible: false
|
|
|
|
})
|
2020-09-24 23:23:47 +00:00
|
|
|
|> Pleroma.Repo.chunk_stream(500)
|
2021-02-04 20:33:49 +00:00
|
|
|
|> Stream.each(&Pleroma.User.maybe_send_confirmation_email(&1))
|
2020-09-08 21:39:08 +00:00
|
|
|
|> Stream.run()
|
|
|
|
end
|
2020-01-20 12:23:21 +00:00
|
|
|
end
|