XML WebFinger user representation correct domain

This commit is contained in:
Alexander Strizhakov 2021-03-04 19:14:00 +03:00 committed by Mark Felder
parent 30ded8876a
commit 5a9ea98baf
1 changed files with 6 additions and 4 deletions

View File

@ -71,10 +71,8 @@ defp gather_aliases(%User{} = user) do
def represent_user(user, "JSON") do def represent_user(user, "JSON") do
{:ok, user} = User.ensure_keys_present(user) {:ok, user} = User.ensure_keys_present(user)
domain = Pleroma.Config.get([__MODULE__, :domain]) || Pleroma.Web.Endpoint.host()
%{ %{
"subject" => "acct:#{user.nickname}@#{domain}", "subject" => "acct:#{user.nickname}@#{domain()}",
"aliases" => gather_aliases(user), "aliases" => gather_aliases(user),
"links" => gather_links(user) "links" => gather_links(user)
} }
@ -94,12 +92,16 @@ def represent_user(user, "XML") do
:XRD, :XRD,
%{xmlns: "http://docs.oasis-open.org/ns/xri/xrd-1.0"}, %{xmlns: "http://docs.oasis-open.org/ns/xri/xrd-1.0"},
[ [
{:Subject, "acct:#{user.nickname}@#{Pleroma.Web.Endpoint.host()}"} {:Subject, "acct:#{user.nickname}@#{domain()}"}
] ++ aliases ++ links ] ++ aliases ++ links
} }
|> XmlBuilder.to_doc() |> XmlBuilder.to_doc()
end end
defp domain do
Pleroma.Config.get([__MODULE__, :domain]) || Pleroma.Web.Endpoint.host()
end
defp webfinger_from_xml(body) do defp webfinger_from_xml(body) do
with {:ok, doc} <- XML.parse_document(body) do with {:ok, doc} <- XML.parse_document(body) do
subject = XML.string_from_xpath("//Subject", doc) subject = XML.string_from_xpath("//Subject", doc)