Merge branch 'restrict-unauthenticated' into 'develop'

InstanceView: expose restrict_unauthenticated settings

See merge request soapbox-pub/rebased!280
This commit is contained in:
Alex Gleason 2023-09-24 17:39:55 +00:00
commit 374b099825
2 changed files with 26 additions and 0 deletions

View file

@ -252,6 +252,21 @@ defp configuration2 do
})
end
defp restrict_unauthenticated do
Config.get([:restrict_unauthenticated])
|> Enum.map(fn {category, features} ->
features =
Enum.map(features, fn
{feature, is_enabled} when is_boolean(is_enabled) -> {feature, is_enabled}
{feature, :if_instance_is_private} -> {feature, !Config.get!([:instance, :public])}
end)
|> Enum.into(%{})
{category, features}
end)
|> Enum.into(%{})
end
defp pleroma_configuration(instance) do
%{
metadata: %{
@ -264,6 +279,7 @@ defp pleroma_configuration(instance) do
birthday_required: Config.get([:instance, :birthday_required]),
birthday_min_age: Config.get([:instance, :birthday_min_age]),
migration_cooldown_period: Config.get([:instance, :migration_cooldown_period]),
restrict_unauthenticated: restrict_unauthenticated(),
translation: translation_configuration(),
markup: markup()
},

View file

@ -204,4 +204,14 @@ test "translation languages matrix", %{conn: conn} do
|> get("/api/v1/instance/translation_languages")
|> json_response_and_validate_schema(200)
end
test "restrict_unauthenticated", %{conn: conn} do
result =
conn
|> get("/api/v1/instance")
|> json_response_and_validate_schema(200)
assert result["pleroma"]["metadata"]["restrict_unauthenticated"]["timelines"]["local"] ==
false
end
end