Also make this maybe_ for consistency
This commit is contained in:
parent
b22b12f738
commit
af37a5c51a
@ -38,7 +38,7 @@ defmodule Mix.Tasks.Pleroma.Email do
|
|||||||
invisible: false
|
invisible: false
|
||||||
})
|
})
|
||||||
|> Pleroma.Repo.chunk_stream(500)
|
|> Pleroma.Repo.chunk_stream(500)
|
||||||
|> Stream.each(&Pleroma.User.try_send_confirmation_email(&1))
|
|> Stream.each(&Pleroma.User.maybe_send_confirmation_email(&1))
|
||||||
|> Stream.run()
|
|> Stream.run()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -798,7 +798,7 @@ defmodule Pleroma.User do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def post_register_action(%User{is_confirmed: false} = user) do
|
def post_register_action(%User{is_confirmed: false} = user) do
|
||||||
with {:ok, _} <- try_send_confirmation_email(user) do
|
with {:ok, _} <- maybe_send_confirmation_email(user) do
|
||||||
{:ok, user}
|
{:ok, user}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -870,8 +870,8 @@ defmodule Pleroma.User do
|
|||||||
|
|
||||||
defp maybe_send_welcome_email(_), do: {:ok, :noop}
|
defp maybe_send_welcome_email(_), do: {:ok, :noop}
|
||||||
|
|
||||||
@spec try_send_confirmation_email(User.t()) :: {:ok, :enqueued | :noop}
|
@spec maybe_send_confirmation_email(User.t()) :: {:ok, :enqueued | :noop}
|
||||||
def try_send_confirmation_email(%User{is_confirmed: false, email: email} = user)
|
def maybe_send_confirmation_email(%User{is_confirmed: false, email: email} = user)
|
||||||
when is_binary(email) do
|
when is_binary(email) do
|
||||||
if Config.get([:instance, :account_activation_required]) do
|
if Config.get([:instance, :account_activation_required]) do
|
||||||
send_confirmation_email(user)
|
send_confirmation_email(user)
|
||||||
@ -881,7 +881,7 @@ defmodule Pleroma.User do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def try_send_confirmation_email(_), do: {:ok, :noop}
|
def maybe_send_confirmation_email(_), do: {:ok, :noop}
|
||||||
|
|
||||||
@spec send_confirmation_email(Uset.t()) :: User.t()
|
@spec send_confirmation_email(Uset.t()) :: User.t()
|
||||||
def send_confirmation_email(%User{} = user) do
|
def send_confirmation_email(%User{} = user) do
|
||||||
|
@ -56,7 +56,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountController do
|
|||||||
nickname_or_email = params[:email] || params[:nickname]
|
nickname_or_email = params[:email] || params[:nickname]
|
||||||
|
|
||||||
with %User{} = user <- User.get_by_nickname_or_email(nickname_or_email),
|
with %User{} = user <- User.get_by_nickname_or_email(nickname_or_email),
|
||||||
{:ok, _} <- User.try_send_confirmation_email(user) do
|
{:ok, _} <- User.maybe_send_confirmation_email(user) do
|
||||||
json_response(conn, :no_content, "")
|
json_response(conn, :no_content, "")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user