X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fpleroma%2Fuser%2Fwelcome_email.ex;h=295c1acc7948ccb33f2826a2aeda5d27092716b1;hb=e7b1f0f5f4d9bb6f7eb384785bd2b0823059e086;hp=53062b961e38ec881c5163184b3d6e991d821911;hpb=3edaecae96975c229c3b8bd7be2dc1208b9bcb82;p=akkoma
diff --git a/lib/pleroma/user/welcome_email.ex b/lib/pleroma/user/welcome_email.ex
index 53062b961..295c1acc7 100644
--- a/lib/pleroma/user/welcome_email.ex
+++ b/lib/pleroma/user/welcome_email.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.User.WelcomeEmail do
@@ -11,7 +11,7 @@ defmodule Pleroma.User.WelcomeEmail do
alias Pleroma.Emails
alias Pleroma.User
- import Pleroma.Config.Utils, only: [instance_name: 0]
+ import Pleroma.Config.Helpers, only: [instance_name: 0]
@spec enabled?() :: boolean()
def enabled?, do: Config.get([:welcome, :email, :enabled], false)
@@ -27,7 +27,7 @@ defmodule Pleroma.User.WelcomeEmail do
bindings = [user: user, instance_name: instance_name()]
%{}
- |> add_sender(Config.get([:welcome, :email, :sender_nickname], nil))
+ |> add_sender(Config.get([:welcome, :email, :sender], nil))
|> add_option(:subject, bindings)
|> add_option(:html, bindings)
|> add_option(:text, bindings)
@@ -40,28 +40,22 @@ defmodule Pleroma.User.WelcomeEmail do
|> merge_options(opts, option)
end
- def add_sender(opts, nickname) do
- nickname
- |> fetch_sender()
- |> merge_options(opts, :sender)
+ defp add_sender(opts, {_name, _email} = sender) do
+ merge_options(sender, opts, :sender)
end
+ defp add_sender(opts, sender) when is_binary(sender) do
+ add_sender(opts, {instance_name(), sender})
+ end
+
+ defp add_sender(opts, _), do: opts
+
defp merge_options(nil, options, _option), do: options
defp merge_options(value, options, option) do
Map.merge(options, %{option => value})
end
- defp fetch_sender(nickname) when is_binary(nickname) do
- with %User{local: true} = user <- User.get_cached_by_nickname(nickname) do
- {instance_name(), user.email}
- else
- _ -> nil
- end
- end
-
- defp fetch_sender(_), do: nil
-
defp eval_string(nil, _), do: nil
defp eval_string("", _), do: nil
defp eval_string(str, bindings), do: EEx.eval_string(str, bindings)