[#2046] Defaulted pleroma/restrict_unauthenticated basing on instance privacy setting (i.e. restrict on private instances only by default).
This commit is contained in:
parent
33e508d7c6
commit
95529ab709
7 changed files with 31 additions and 37 deletions
|
|
@ -81,6 +81,16 @@ defmodule Pleroma.Config do
|
|||
Application.delete_env(:pleroma, key)
|
||||
end
|
||||
|
||||
def restrict_unauthenticated_access?(resource, kind) do
|
||||
setting = get([:restrict_unauthenticated, resource, kind])
|
||||
|
||||
if setting in [nil, :if_instance_is_private] do
|
||||
!get!([:instance, :public])
|
||||
else
|
||||
setting
|
||||
end
|
||||
end
|
||||
|
||||
def oauth_consumer_strategies, do: get([:auth, :oauth_consumer_strategies], [])
|
||||
|
||||
def oauth_consumer_enabled?, do: oauth_consumer_strategies() != []
|
||||
|
|
|
|||
|
|
@ -311,10 +311,12 @@ defmodule Pleroma.User do
|
|||
|
||||
def visible_for(_, _), do: :invisible
|
||||
|
||||
defp restrict_unauthenticated?(%User{local: local}) do
|
||||
config_key = if local, do: :local, else: :remote
|
||||
defp restrict_unauthenticated?(%User{local: true}) do
|
||||
Config.restrict_unauthenticated_access?(:profiles, :local)
|
||||
end
|
||||
|
||||
Config.get([:restrict_unauthenticated, :profiles, config_key], false)
|
||||
defp restrict_unauthenticated?(%User{local: _}) do
|
||||
Config.restrict_unauthenticated_access?(:profiles, :remote)
|
||||
end
|
||||
|
||||
defp visible_account_status(user) do
|
||||
|
|
|
|||
|
|
@ -59,12 +59,9 @@ defmodule Pleroma.Web.ActivityPub.Visibility do
|
|||
end
|
||||
|
||||
def visible_for_user?(%{local: local} = activity, nil) do
|
||||
cfg_key =
|
||||
if local,
|
||||
do: :local,
|
||||
else: :remote
|
||||
cfg_key = if local, do: :local, else: :remote
|
||||
|
||||
if Pleroma.Config.get([:restrict_unauthenticated, :activities, cfg_key]),
|
||||
if Pleroma.Config.restrict_unauthenticated_access?(:activities, cfg_key),
|
||||
do: false,
|
||||
else: is_public?(activity)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineController do
|
|||
import Pleroma.Web.ControllerHelper,
|
||||
only: [add_link_headers: 2, add_link_headers: 3]
|
||||
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.Pagination
|
||||
alias Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug
|
||||
alias Pleroma.Plugs.OAuthScopesPlug
|
||||
|
|
@ -89,11 +90,11 @@ defmodule Pleroma.Web.MastodonAPI.TimelineController do
|
|||
end
|
||||
|
||||
defp restrict_unauthenticated?(true = _local_only) do
|
||||
Pleroma.Config.get([:restrict_unauthenticated, :timelines, :local])
|
||||
Config.restrict_unauthenticated_access?(:timelines, :local)
|
||||
end
|
||||
|
||||
defp restrict_unauthenticated?(_) do
|
||||
Pleroma.Config.get([:restrict_unauthenticated, :timelines, :federated])
|
||||
Config.restrict_unauthenticated_access?(:timelines, :federated)
|
||||
end
|
||||
|
||||
# GET /api/v1/timelines/public
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ defmodule Pleroma.Web.Preload.Providers.Timelines do
|
|||
end
|
||||
|
||||
def build_public_tag(acc, params) do
|
||||
if Pleroma.Config.get([:restrict_unauthenticated, :timelines, :federated], true) do
|
||||
if Pleroma.Config.restrict_unauthenticated_access?(:timelines, :federated) do
|
||||
acc
|
||||
else
|
||||
Map.put(acc, @public_url, public_timeline(params))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue