mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2026-02-15 17:16:57 +00:00
InstanceView: expose restrict_unauthenticated settings
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
parent
606c9ae4b1
commit
0277b4e88c
2 changed files with 27 additions and 1 deletions
|
|
@ -261,6 +261,21 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView 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
|
||||
base_urls = %{}
|
||||
|
||||
|
|
@ -288,7 +303,8 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do
|
|||
birthday_min_age: Config.get([:instance, :birthday_min_age]),
|
||||
translation: supported_languages(),
|
||||
base_urls: base_urls,
|
||||
markup: markup()
|
||||
markup: markup(),
|
||||
restrict_unauthenticated: restrict_unauthenticated()
|
||||
},
|
||||
stats: %{mau: Pleroma.User.active_user_count()},
|
||||
vapid_public_key: Keyword.get(Pleroma.Web.Push.vapid_config(), :public_key)
|
||||
|
|
|
|||
|
|
@ -194,4 +194,14 @@ defmodule Pleroma.Web.MastodonAPI.InstanceControllerTest do
|
|||
refute Map.has_key?(result["pleroma"]["metadata"]["base_urls"], "media_proxy")
|
||||
refute Map.has_key?(result["pleroma"]["metadata"]["base_urls"], "upload")
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue