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 def build_tags(params) do
providers = [ providers = [
Pleroma.Web.Metadata.Providers.Feed,
Pleroma.Web.Metadata.Providers.RelMe, Pleroma.Web.Metadata.Providers.RelMe,
Pleroma.Web.Metadata.Providers.RestrictIndexing Pleroma.Web.Metadata.Providers.RestrictIndexing
| activated_providers() | activated_providers()
@ -47,7 +46,7 @@ defmodule Pleroma.Web.Metadata do
defp activated_providers do defp activated_providers do
unless Pleroma.Config.restrict_unauthenticated_access?(:activities, :local) 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 else
[] []
end end

View file

@ -11,7 +11,6 @@ defmodule Pleroma.Web.Metadata.Providers.Feed do
@impl Provider @impl Provider
def build_tags(%{user: user}) do def build_tags(%{user: user}) do
if Pleroma.Config.get!([:instance, :public]) do
[ [
{:link, {:link,
[ [
@ -20,8 +19,5 @@ defmodule Pleroma.Web.Metadata.Providers.Feed do
href: Helpers.user_feed_path(Endpoint, :feed, user.nickname) <> ".atom" href: Helpers.user_feed_path(Endpoint, :feed, user.nickname) <> ".atom"
], []} ], []}
] ]
else
[]
end
end end
end end

View file

@ -24,10 +24,8 @@ defmodule Pleroma.Web.MetadataTest do
end end
describe "no metadata for private instances" do describe "no metadata for private instances" do
setup do: clear_config([:instance, :public])
test "for local user" do 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") user = insert(:user, bio: "This is my secret fedi account bio")
assert "" = Pleroma.Web.Metadata.build_tags(%{user: user}) assert "" = Pleroma.Web.Metadata.build_tags(%{user: user})