diff --git a/config/config.exs b/config/config.exs index e919910b3..3870b0bcc 100644 --- a/config/config.exs +++ b/config/config.exs @@ -273,7 +273,8 @@ local_bubble: [], max_frontend_settings_json_chars: 100_000, export_prometheus_metrics: true, - federated_timeline_available: true + federated_timeline_available: true, + local_timeline_available: true config :pleroma, :welcome, direct_message: [ diff --git a/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex b/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex index 1d4e734a4..a14f220cc 100644 --- a/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex @@ -122,8 +122,14 @@ def public(%{assigns: %{user: user}} = conn, params) do local_only = params[:local] timeline_type = if local_only, do: :local, else: :federated + timeline_enabled = + case timeline_type do + :local -> Config.get([:instance, :local_timeline_available], true) + :federated -> Config.get([:instance, :federated_timeline_available], true) + end + with {:enabled, true} <- - {:enabled, local_only || Config.get([:instance, :federated_timeline_available], true)}, + {:enabled, timeline_enabled}, {:authenticated, true} <- {:authenticated, !(is_nil(user) and restrict_unauthenticated?(timeline_type))} do Logger.debug("TimelineController.public: fetching activities") @@ -152,9 +158,15 @@ def public(%{assigns: %{user: user}} = conn, params) do ) else {:enabled, false} -> + error_msg = + case timeline_type do + :local -> "Local timeline is disabled" + :federated -> "Federated timeline is disabled" + end + conn |> put_status(404) - |> json(%{error: "Federated timeline is disabled"}) + |> json(%{error: error_msg}) {:authenticated, false} -> fail_on_bad_auth(conn)