Add option to disable local timeline

This commit is contained in:
Ruby Iris Juric 2024-09-21 14:57:35 +10:00
parent 3c72b48a05
commit 53485639e8
Signed by: srxl
GPG key ID: B6D7116C451A5B41
2 changed files with 16 additions and 3 deletions

View file

@ -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: [

View file

@ -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)