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