Metadata: Move restriction check from Feed provider to activated_providers

This commit is contained in:
rinpatch 2020-09-07 15:06:06 +03:00
parent 2011142ed9
commit 0d2814ec8e
3 changed files with 10 additions and 17 deletions

View file

@ -7,7 +7,6 @@ defmodule Pleroma.Web.Metadata do
def build_tags(params) do
providers = [
Pleroma.Web.Metadata.Providers.Feed,
Pleroma.Web.Metadata.Providers.RelMe,
Pleroma.Web.Metadata.Providers.RestrictIndexing
| activated_providers()
@ -47,7 +46,7 @@ def activity_nsfw?(_) do
defp activated_providers do
unless Pleroma.Config.restrict_unauthenticated_access?(:activities, :local) do
Pleroma.Config.get([__MODULE__, :providers], [])
[Pleroma.Web.Metadata.Providers.Feed | Pleroma.Config.get([__MODULE__, :providers], [])]
else
[]
end

View file

@ -11,17 +11,13 @@ defmodule Pleroma.Web.Metadata.Providers.Feed do
@impl Provider
def build_tags(%{user: user}) do
if Pleroma.Config.get!([:instance, :public]) do
[
{:link,
[
rel: "alternate",
type: "application/atom+xml",
href: Helpers.user_feed_path(Endpoint, :feed, user.nickname) <> ".atom"
], []}
]
else
[]
end
[
{:link,
[
rel: "alternate",
type: "application/atom+xml",
href: Helpers.user_feed_path(Endpoint, :feed, user.nickname) <> ".atom"
], []}
]
end
end

View file

@ -24,10 +24,8 @@ test "for local user" do
end
describe "no metadata for private instances" do
setup do: clear_config([:instance, :public])
test "for local user" do
Pleroma.Config.put([:instance, :public], false)
clear_config([:instance, :public], false)
user = insert(:user, bio: "This is my secret fedi account bio")
assert "" = Pleroma.Web.Metadata.build_tags(%{user: user})