Commit 269d3e1c authored by lain's avatar lain

WelcomeMessage: Get rid of Ecto reference.

parent f469a861
defmodule Pleroma.User.WelcomeMessage do
alias Pleroma.User
alias Pleroma.Web.CommonAPI
import Ecto.Query
def post_welcome_message_to_user(user) do
with %User{} = sender_user <- welcome_user(),
......@@ -16,14 +15,12 @@ defmodule Pleroma.User.WelcomeMessage do
end
defp welcome_user() do
if nickname = Pleroma.Config.get([:instance, :welcome_user_nickname]) do
from(u in User,
where: u.local == true,
where: u.nickname == ^nickname
)
|> Pleroma.Repo.one()
with nickname when is_binary(nickname) <-
Pleroma.Config.get([:instance, :welcome_user_nickname]),
%User{local: true} = user <- User.get_cached_by_nickname(nickname) do
user
else
nil
_ -> nil
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment