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