Merge branch 'webfinger-fix' into 'develop'

Use correct domain for fqn and InstanceView

See merge request soapbox-pub/rebased!215
This commit is contained in:
marcin mikołajczak 2022-11-22 23:31:52 +00:00
commit 5866789d46
4 changed files with 20 additions and 8 deletions

View file

@ -2253,7 +2253,7 @@ def full_nickname(%User{} = user) do
if String.contains?(user.nickname, "@") do
user.nickname
else
%{host: host} = URI.parse(user.ap_id)
host = Pleroma.Web.WebFinger.domain()
user.nickname <> "@" <> host
end
end

View file

@ -21,7 +21,7 @@ def render("show.json", _) do
instance = Config.get(:instance)
%{
uri: Pleroma.Web.Endpoint.url(),
uri: Pleroma.Web.WebFinger.domain(),
title: Keyword.get(instance, :name),
description: Keyword.get(instance, :description),
short_description: Keyword.get(instance, :short_description),
@ -61,7 +61,7 @@ def render("show2.json", _) do
instance = Config.get(:instance)
%{
domain: Pleroma.Web.Endpoint.url(),
domain: Pleroma.Web.WebFinger.domain(),
title: Keyword.get(instance, :name),
version: "#{@mastodon_api_level} (compatible; #{Pleroma.Application.compat_version()})",
source_url: Pleroma.Application.repository(),

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

@ -2614,13 +2614,25 @@ test "returns nickname without host" do
end
describe "full_nickname/1" do
test "returns fully qualified nickname for local and remote users" do
local_user =
insert(:user, nickname: "local_user", ap_id: "https://somehost.com/users/local_user")
test "returns fully qualified nickname for local users" do
local_user = insert(:user, nickname: "local_user")
assert User.full_nickname(local_user) == "local_user@localhost"
end
test "returns fully qualified nickname for local users when using different domain for webfinger" do
clear_config([Pleroma.Web.WebFinger, :domain], "plemora.dev")
host = Pleroma.Web.Endpoint.host()
local_user = insert(:user, nickname: "local_user")
assert User.full_nickname(local_user) == "local_user@plemora.dev"
end
test "returns fully qualified nickname for remote users" do
remote_user = insert(:user, nickname: "remote@host.com", local: false)
assert User.full_nickname(local_user) == "local_user@somehost.com"
assert User.full_nickname(remote_user) == "remote@host.com"
end