diff --git a/lib/pleroma/web/mastodon_api/views/instance_view.ex b/lib/pleroma/web/mastodon_api/views/instance_view.ex index 8237b2aad5..0decd2559b 100644 --- a/lib/pleroma/web/mastodon_api/views/instance_view.ex +++ b/lib/pleroma/web/mastodon_api/views/instance_view.ex @@ -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() }, diff --git a/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs index 04e1360569..32cb6f2585 100644 --- a/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs @@ -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