Handle possibility of user account in a bulk operation not having an email address
authorMark Felder <feld@FreeBSD.org>
Tue, 8 Sep 2020 21:48:54 +0000 (16:48 -0500)
committerMark Felder <feld@FreeBSD.org>
Tue, 8 Sep 2020 21:48:54 +0000 (16:48 -0500)
lib/mix/tasks/pleroma/email.ex
lib/pleroma/user.ex

index 61d4319719b4f8b93fee5a0b4fb67e5a109f06fb..c0bef03861c96d2a4e596764af13af9eea6a18cd 100644 (file)
@@ -34,7 +34,7 @@ defmodule Mix.Tasks.Pleroma.Email do
     |> Pleroma.RepoStreamer.chunk_stream(500)
     |> Stream.each(fn users ->
       users
-      |> Enum.each(fn user -> Pleroma.User.send_confirmation_email(user) end)
+      |> Enum.each(fn user -> Pleroma.User.try_send_confirmation_email(user) end)
     end)
     |> Stream.run()
   end
index 603fc3b4459ebf0d1f30bb18cc68a11bec460ce4..9dea3961951fe6bea00c4f0761c3c1806cf652cc 100644 (file)
@@ -814,7 +814,8 @@ defmodule Pleroma.User do
   def send_welcome_email(_), do: {:ok, :noop}
 
   @spec try_send_confirmation_email(User.t()) :: {:ok, :enqueued | :noop}
-  def try_send_confirmation_email(%User{confirmation_pending: true} = user) do
+  def try_send_confirmation_email(%User{confirmation_pending: true, email: email} = user)
+      when is_binary(email) do
     if Config.get([:instance, :account_activation_required]) do
       send_confirmation_email(user)
       {:ok, :enqueued}