WelcomeMessage: Get rid of Ecto reference.

This commit is contained in:
lain 2019-02-16 17:24:48 +01:00
parent f469a8610f
commit 269d3e1ca6

View file

@ -1,7 +1,6 @@
defmodule Pleroma.User.WelcomeMessage do defmodule Pleroma.User.WelcomeMessage do
alias Pleroma.User alias Pleroma.User
alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI
import Ecto.Query
def post_welcome_message_to_user(user) do def post_welcome_message_to_user(user) do
with %User{} = sender_user <- welcome_user(), with %User{} = sender_user <- welcome_user(),
@ -16,14 +15,12 @@ def post_welcome_message_to_user(user) do
end end
defp welcome_user() do defp welcome_user() do
if nickname = Pleroma.Config.get([:instance, :welcome_user_nickname]) do with nickname when is_binary(nickname) <-
from(u in User, Pleroma.Config.get([:instance, :welcome_user_nickname]),
where: u.local == true, %User{local: true} = user <- User.get_cached_by_nickname(nickname) do
where: u.nickname == ^nickname user
)
|> Pleroma.Repo.one()
else else
nil _ -> nil
end end
end end