Merge branch 'metadata_webfinger' into develop
ci/woodpecker/push/build-amd64 Pipeline is pending Details
ci/woodpecker/push/build-arm64 Pipeline is pending Details
ci/woodpecker/push/docs Pipeline is pending Details
ci/woodpecker/push/test Pipeline is pending Details

This commit is contained in:
FloatingGhost 2023-08-02 12:05:43 +01:00
commit babb4b9a8f
3 changed files with 18 additions and 2 deletions

View File

@ -55,7 +55,7 @@ defmodule Pleroma.Web.Metadata.Utils do
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

View File

@ -96,7 +96,7 @@ defmodule Pleroma.Web.WebFinger do
|> XmlBuilder.to_doc()
end
defp domain do
def domain do
Pleroma.Config.get([__MODULE__, :domain]) || Pleroma.Web.Endpoint.host()
end

View File

@ -77,4 +77,20 @@ defmodule Pleroma.Web.Metadata.UtilsTest 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