logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/
commit: ec51aadc78f51067315245c2fbc2925f584fc3be
parent 9548c31ef997e4c84cbdc7dc534873c921b32e42
Author: nicole mikołajczyk <me@mkljczk.pl>
Date:   Fri, 28 Nov 2025 14:50:46 +0100

Merge branch 'instance-view-timeline-access' into 'develop'

Add `timelines_access` to InstanceView

See merge request pleroma/pleroma!4393

Diffstat:

Achangelog.d/instance-view-timeline-access.add1+
Mlib/pleroma/web/mastodon_api/views/instance_view.ex26+++++++++++++++++++++++++-
Mtest/pleroma/web/mastodon_api/controllers/instance_controller_test.exs24++++++++++++++++++++++++
3 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/changelog.d/instance-view-timeline-access.add b/changelog.d/instance-view-timeline-access.add @@ -0,0 +1 @@ +Add `timelines_access` to InstanceView diff --git a/lib/pleroma/web/mastodon_api/views/instance_view.ex b/lib/pleroma/web/mastodon_api/views/instance_view.ex @@ -257,10 +257,34 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do vapid: %{ public_key: Keyword.get(Pleroma.Web.Push.vapid_config(), :public_key) }, - translation: %{enabled: Pleroma.Language.Translation.configured?()} + translation: %{enabled: Pleroma.Language.Translation.configured?()}, + timelines_access: %{ + live_feeds: timelines_access(), + hashtag_feeds: timelines_access(), + # not implemented in Pleroma + trending_link_feeds: %{ + local: "disabled", + remote: "disabled" + } + } }) end + defp timelines_access do + %{ + local: timeline_access(:local), + remote: timeline_access(:federated) + } + end + + defp timeline_access(kind) do + if Config.restrict_unauthenticated_access?(:timelines, kind) do + "authenticated" + else + "public" + end + end + defp pleroma_configuration(instance) do base_urls = %{} diff --git a/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs @@ -194,4 +194,28 @@ 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 "display timeline access restrictions", %{conn: conn} do + clear_config([:restrict_unauthenticated, :timelines, :local], true) + clear_config([:restrict_unauthenticated, :timelines, :federated], false) + + conn = get(conn, "/api/v2/instance") + + assert result = json_response_and_validate_schema(conn, 200) + + assert result["configuration"]["timelines_access"] == %{ + "live_feeds" => %{ + "local" => "authenticated", + "remote" => "public" + }, + "hashtag_feeds" => %{ + "local" => "authenticated", + "remote" => "public" + }, + "trending_link_feeds" => %{ + "local" => "disabled", + "remote" => "disabled" + } + } + end end