Support reaching user@sub.domain.tld at user@domain.tld #134

Merged
floatingghost merged 6 commits from TnSb/akkoma:feature/1469-webfinger-expanding into develop 2022-08-02 13:54:22 +00:00
1 changed files with 6 additions and 4 deletions
Showing only changes of commit 3f66e88a9b - Show all commits

View File

@ -71,10 +71,8 @@ defmodule Pleroma.Web.WebFinger do
def represent_user(user, "JSON") do
{: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),
"links" => gather_links(user)
}
@ -96,12 +94,16 @@ defmodule Pleroma.Web.WebFinger do
:XRD,
%{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
}
|> XmlBuilder.to_doc()
end
defp domain do
Pleroma.Config.get([__MODULE__, :domain]) || Pleroma.Web.Endpoint.host()
end
defp webfinger_from_xml(body) do
with {:ok, doc} <- XML.parse_document(body) do
subject = XML.string_from_xpath("//Subject", doc)