Metadata: Move restriction check from Feed provider to activated_providers
authorrinpatch <rinpatch@sdf.org>
Mon, 7 Sep 2020 12:06:06 +0000 (15:06 +0300)
committerrinpatch <rinpatch@sdf.org>
Tue, 8 Sep 2020 17:21:34 +0000 (20:21 +0300)
lib/pleroma/web/metadata.ex
lib/pleroma/web/metadata/feed.ex
test/web/metadata/metadata_test.exs

index 68835c8263b12e23062dce424220655b941cf661..0f2d8d1e73635f48ee9bfc0720bb8ede642ff726 100644 (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 @@ defmodule Pleroma.Web.Metadata 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
index dfe391b56163842b0802c6273a5d1dee07504cb1..bd1459a171f2eaf782f4d1d5c5cbcd19ddf80d76 100644 (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
index f7371cae230a91653b0f11b88affa2e983f8ac54..9d3121b7bb876eea8dc2a980d640193e1a954285 100644 (file)
@@ -24,10 +24,8 @@ defmodule Pleroma.Web.MetadataTest 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})