Add publicTimelineVisibility to nodeinfo

This commit is contained in:
FloatingGhost 2023-03-15 22:13:18 +00:00
parent 377d1483b6
commit 9464d50562
2 changed files with 35 additions and 1 deletions

View file

@ -89,7 +89,11 @@ def raw_nodeinfo do
features: features, features: features,
restrictedNicknames: Config.get([Pleroma.User, :restricted_nicknames]), restrictedNicknames: Config.get([Pleroma.User, :restricted_nicknames]),
skipThreadContainment: Config.get([:instance, :skip_thread_containment], false), skipThreadContainment: Config.get([:instance, :skip_thread_containment], false),
localBubbleInstances: Config.get([:instance, :local_bubble], []) localBubbleInstances: Config.get([:instance, :local_bubble], []),
publicTimelineVisibility: %{
federated: !Config.restrict_unauthenticated_access?(:timelines, :federated),
local: !Config.restrict_unauthenticated_access?(:timelines, :local)
}
} }
} }
end end

View file

@ -292,4 +292,34 @@ test "shows extra information in the mrf_simple_info field for relevant entries"
assert response["metadata"]["federation"]["mrf_simple_info"] == expected_config assert response["metadata"]["federation"]["mrf_simple_info"] == expected_config
end end
end end
describe "public timeline visibility" do
test "shows public timeline visibility", %{conn: conn} do
clear_config([:restrict_unauthenticated, :timelines], %{local: false, federated: false})
response =
conn
|> get("/nodeinfo/2.1.json")
|> json_response(:ok)
assert response["metadata"]["publicTimelineVisibility"]["local"] == true
assert response["metadata"]["publicTimelineVisibility"]["federated"] == true
clear_config([:restrict_unauthenticated, :timelines], %{local: true, federated: false})
response =
conn
|> get("/nodeinfo/2.1.json")
|> json_response(:ok)
assert response["metadata"]["publicTimelineVisibility"]["local"] == false
assert response["metadata"]["publicTimelineVisibility"]["federated"] == true
clear_config([:restrict_unauthenticated, :timelines], %{local: false, federated: true})
response =
conn
|> get("/nodeinfo/2.1.json")
|> json_response(:ok)
assert response["metadata"]["publicTimelineVisibility"]["local"] == true
assert response["metadata"]["publicTimelineVisibility"]["federated"] == false
end
end
end end