forked from AkkomaGang/akkoma
Make it possible to bulk send confirmation emails to all unconfirmed users
This commit is contained in:
parent
7c055af567
commit
23ca5f75af
3 changed files with 37 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
||||||
# Managing emails
|
# E-Mail administration tasks
|
||||||
|
|
||||||
{! backend/administration/CLI_tasks/general_cli_task_info.include !}
|
{! backend/administration/CLI_tasks/general_cli_task_info.include !}
|
||||||
|
|
||||||
|
@ -30,3 +30,17 @@ Example:
|
||||||
```sh
|
```sh
|
||||||
mix pleroma.email test --to root@example.org
|
mix pleroma.email test --to root@example.org
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Send confirmation emails to all unconfirmed user accounts
|
||||||
|
|
||||||
|
=== "OTP"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./bin/pleroma_ctl email send_confirmation_mails
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.email send_confirmation_mails
|
||||||
|
```
|
||||||
|
|
|
@ -2,7 +2,7 @@ defmodule Mix.Tasks.Pleroma.Email do
|
||||||
use Mix.Task
|
use Mix.Task
|
||||||
import Mix.Pleroma
|
import Mix.Pleroma
|
||||||
|
|
||||||
@shortdoc "Simple Email test"
|
@shortdoc "Email administrative tasks"
|
||||||
@moduledoc File.read!("docs/administration/CLI_tasks/email.md")
|
@moduledoc File.read!("docs/administration/CLI_tasks/email.md")
|
||||||
|
|
||||||
def run(["test" | args]) do
|
def run(["test" | args]) do
|
||||||
|
@ -21,4 +21,21 @@ def run(["test" | args]) do
|
||||||
|
|
||||||
shell_info("Test email has been sent to #{inspect(email.to)} from #{inspect(email.from)}")
|
shell_info("Test email has been sent to #{inspect(email.to)} from #{inspect(email.from)}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def run(["resend_confirmation_emails"]) do
|
||||||
|
start_pleroma()
|
||||||
|
|
||||||
|
Pleroma.User.Query.build(%{
|
||||||
|
local: true,
|
||||||
|
deactivated: false,
|
||||||
|
confirmation_pending: true,
|
||||||
|
invisible: false
|
||||||
|
})
|
||||||
|
|> Pleroma.RepoStreamer.chunk_stream(500)
|
||||||
|
|> Stream.each(fn users ->
|
||||||
|
users
|
||||||
|
|> Enum.each(fn user -> Pleroma.User.send_confirmation_email(user) end)
|
||||||
|
end)
|
||||||
|
|> Stream.run()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -148,6 +148,10 @@ defp compose_query({:deactivated, true}, query) do
|
||||||
|> where([u], not is_nil(u.nickname))
|
|> where([u], not is_nil(u.nickname))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp compose_query({:confirmation_pending, bool}, query) do
|
||||||
|
where(query, [u], u.confirmation_pending == ^bool)
|
||||||
|
end
|
||||||
|
|
||||||
defp compose_query({:need_approval, _}, query) do
|
defp compose_query({:need_approval, _}, query) do
|
||||||
where(query, [u], u.approval_pending)
|
where(query, [u], u.approval_pending)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue