mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-23 06:58:58 +00:00
search indexing metadata respects discoverable flag
This commit is contained in:
parent
6e70415e4a
commit
38b2db297b
|
@ -10,7 +10,9 @@ defmodule Pleroma.Web.Metadata.Providers.RestrictIndexing do
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def build_tags(%{user: %{local: false}}) do
|
def build_tags(%{user: %{local: true, discoverable: true}}), do: []
|
||||||
|
|
||||||
|
def build_tags(_) do
|
||||||
[
|
[
|
||||||
{:meta,
|
{:meta,
|
||||||
[
|
[
|
||||||
|
@ -19,7 +21,4 @@ defmodule Pleroma.Web.Metadata.Providers.RestrictIndexing do
|
||||||
], []}
|
], []}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
|
||||||
def build_tags(%{user: %{local: true}}), do: []
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,17 +18,32 @@ defmodule Pleroma.Web.MetadataTest do
|
||||||
test "for local user" do
|
test "for local user" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
|
assert Pleroma.Web.Metadata.build_tags(%{user: user}) =~
|
||||||
|
"<meta content=\"noindex, noarchive\" name=\"robots\">"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "for local user set to discoverable" do
|
||||||
|
user = insert(:user, discoverable: true)
|
||||||
|
|
||||||
refute Pleroma.Web.Metadata.build_tags(%{user: user}) =~
|
refute Pleroma.Web.Metadata.build_tags(%{user: user}) =~
|
||||||
"<meta content=\"noindex, noarchive\" name=\"robots\">"
|
"<meta content=\"noindex, noarchive\" name=\"robots\">"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "no metadata for private instances" do
|
describe "no metadata for private instances" do
|
||||||
test "for local user" do
|
test "for local user set to discoverable" do
|
||||||
clear_config([: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", discoverable: true)
|
||||||
|
|
||||||
assert "" = Pleroma.Web.Metadata.build_tags(%{user: user})
|
assert "" = Pleroma.Web.Metadata.build_tags(%{user: user})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "search exclusion metadata is included" do
|
||||||
|
clear_config([:instance, :public], false)
|
||||||
|
user = insert(:user, bio: "This is my secret fedi account bio")
|
||||||
|
|
||||||
|
assert "<meta content=\"noindex, noarchive\" name=\"robots\">" ==
|
||||||
|
Pleroma.Web.Metadata.build_tags(%{user: user})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,8 +14,14 @@ defmodule Pleroma.Web.Metadata.Providers.RestrictIndexingTest do
|
||||||
|
|
||||||
test "for local user" do
|
test "for local user" do
|
||||||
assert Pleroma.Web.Metadata.Providers.RestrictIndexing.build_tags(%{
|
assert Pleroma.Web.Metadata.Providers.RestrictIndexing.build_tags(%{
|
||||||
user: %Pleroma.User{local: true}
|
user: %Pleroma.User{local: true, discoverable: true}
|
||||||
}) == []
|
}) == []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "for local user when discoverable is false" do
|
||||||
|
assert Pleroma.Web.Metadata.Providers.RestrictIndexing.build_tags(%{
|
||||||
|
user: %Pleroma.User{local: true, discoverable: false}
|
||||||
|
}) == [{:meta, [name: "robots", content: "noindex, noarchive"], []}]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue