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

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 @@ 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

View file

@ -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

View file

@ -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