Merge branch 'metadata_webfinger' into develop

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 def user_name_string(user) do
"#{user.name} " <> "#{user.name} " <>
if user.local do if user.local do
"(@#{user.nickname}@#{Pleroma.Web.Endpoint.host()})" "(@#{user.nickname}@#{Pleroma.Web.WebFinger.domain()})"
else else
"(@#{user.nickname})" "(@#{user.nickname})"
end end

View file

@ -96,7 +96,7 @@ def represent_user(user, "XML") do
|> XmlBuilder.to_doc() |> XmlBuilder.to_doc()
end end
defp domain do def domain do
Pleroma.Config.get([__MODULE__, :domain]) || Pleroma.Web.Endpoint.host() Pleroma.Config.get([__MODULE__, :domain]) || Pleroma.Web.Endpoint.host()
end 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!" assert Utils.scrub_html_and_truncate("Pleroma's really cool!") == "Pleroma's really cool!"
end end
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 end