diff --git a/lib/pleroma/web/metadata/utils.ex b/lib/pleroma/web/metadata/utils.ex index 7308726f5..92622ef15 100644 --- a/lib/pleroma/web/metadata/utils.ex +++ b/lib/pleroma/web/metadata/utils.ex @@ -55,7 +55,7 @@ def scrub_html(content), do: content def user_name_string(user) do "#{user.name} " <> if user.local do - "(@#{user.nickname}@#{Pleroma.Web.Endpoint.host()})" + "(@#{user.nickname}@#{Pleroma.Web.WebFinger.domain()})" else "(@#{user.nickname})" end diff --git a/lib/pleroma/web/web_finger.ex b/lib/pleroma/web/web_finger.ex index 364d0e0e6..ae3993f90 100644 --- a/lib/pleroma/web/web_finger.ex +++ b/lib/pleroma/web/web_finger.ex @@ -96,7 +96,7 @@ def represent_user(user, "XML") do |> XmlBuilder.to_doc() end - defp domain do + def domain do Pleroma.Config.get([__MODULE__, :domain]) || Pleroma.Web.Endpoint.host() end diff --git a/test/pleroma/web/metadata/utils_test.exs b/test/pleroma/web/metadata/utils_test.exs index 665efb9ca..32bc86942 100644 --- a/test/pleroma/web/metadata/utils_test.exs +++ b/test/pleroma/web/metadata/utils_test.exs @@ -77,4 +77,20 @@ test "it returns text without encode HTML" do assert Utils.scrub_html_and_truncate("Pleroma's really cool!") == "Pleroma's really cool!" end end + + describe "user_name_string/1" do + test "it uses the Endpoint by default" do + user = insert(:user) + + assert Utils.user_name_string(user) == "#{user.name} (@#{user.nickname}@localhost)" + end + + test "it uses any custom WebFinger domain" do + clear_config([Pleroma.Web.WebFinger, :domain], "example.com") + + user = insert(:user) + + assert Utils.user_name_string(user) == "#{user.name} (@#{user.nickname}@example.com)" + end + end end