Documentation updates for stable release (#73)
[akkoma] / lib / mix / tasks / pleroma / email.ex
index d3fac6ec8f3420da3ec0b765932b49ba432f42e6..d257cebe96fd262d09e4d61763f52973d98010db 100644 (file)
@@ -1,12 +1,16 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
 defmodule Mix.Tasks.Pleroma.Email do
   use Mix.Task
   import Mix.Pleroma
 
-  @shortdoc "Simple Email test"
-  @moduledoc File.read!("docs/administration/CLI_tasks/email.md")
+  @shortdoc "Email administrative tasks"
+  @moduledoc File.read!("docs/docs/administration/CLI_tasks/email.md")
 
   def run(["test" | args]) do
-    Mix.Pleroma.start_pleroma()
+    start_pleroma()
 
     {options, [], []} =
       OptionParser.parse(
@@ -21,4 +25,20 @@ defmodule Mix.Tasks.Pleroma.Email do
 
     shell_info("Test email has been sent to #{inspect(email.to)} from #{inspect(email.from)}")
   end
+
+  def run(["resend_confirmation_emails"]) do
+    start_pleroma()
+
+    shell_info("Sending emails to all unconfirmed users")
+
+    Pleroma.User.Query.build(%{
+      local: true,
+      is_active: true,
+      is_confirmed: false,
+      invisible: false
+    })
+    |> Pleroma.Repo.chunk_stream(500)
+    |> Stream.each(&Pleroma.User.maybe_send_confirmation_email(&1))
+    |> Stream.run()
+  end
 end