[#2301] Proper handling of User.is_discoverable: users appear in in-service search but are hidden from external services like search bots.
This commit is contained in:
parent
fcad3e716a
commit
e164c37139
13 changed files with 16 additions and 66 deletions
|
|
@ -65,8 +65,8 @@ defmodule Pleroma.UserSearchTest do
|
|||
assert found_user.id == user.id
|
||||
end
|
||||
|
||||
# NOTE: as long as users are non-discoverable by default, we can't filter out most users: #2301
|
||||
test "does NOT exclude non-discoverable users from results (as long as it's the default)" do
|
||||
# Note: as in Mastodon, `is_discoverable` doesn't anyhow relate to user searchability
|
||||
test "includes non-discoverable users in results" do
|
||||
insert(:user, %{nickname: "john 3000", is_discoverable: false})
|
||||
insert(:user, %{nickname: "john 3001"})
|
||||
|
||||
|
|
|
|||
|
|
@ -203,6 +203,7 @@ defmodule Pleroma.Web.AdminAPI.SearchTest do
|
|||
assert count == 1
|
||||
end
|
||||
|
||||
# Note: as in Mastodon, `is_discoverable` doesn't anyhow relate to user searchability
|
||||
test "it returns non-discoverable users" do
|
||||
insert(:user)
|
||||
insert(:user, is_discoverable: false)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ defmodule Pleroma.Web.Metadata.Providers.RestrictIndexingTest do
|
|||
}) == []
|
||||
end
|
||||
|
||||
test "for local user when discoverable is false" do
|
||||
test "for local user when `is_discoverable` is false" do
|
||||
assert Pleroma.Web.Metadata.Providers.RestrictIndexing.build_tags(%{
|
||||
user: %Pleroma.User{local: true, is_discoverable: false}
|
||||
}) == [{:meta, [name: "robots", content: "noindex, noarchive"], []}]
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.MetadataTest do
|
||||
use Pleroma.DataCase, async: true
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
describe "restrict indexing remote users" do
|
||||
test "for remote user" do
|
||||
user = insert(:user, local: false)
|
||||
|
||||
assert Pleroma.Web.Metadata.build_tags(%{user: user}) =~
|
||||
"<meta content=\"noindex, noarchive\" name=\"robots\">"
|
||||
end
|
||||
|
||||
test "for local user" do
|
||||
user = insert(:user, is_discoverable: false)
|
||||
|
||||
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, is_discoverable: true)
|
||||
|
||||
refute Pleroma.Web.Metadata.build_tags(%{user: user}) =~
|
||||
"<meta content=\"noindex, noarchive\" name=\"robots\">"
|
||||
end
|
||||
end
|
||||
|
||||
describe "no metadata for private instances" do
|
||||
test "for local user set to discoverable" do
|
||||
clear_config([:instance, :public], false)
|
||||
user = insert(:user, bio: "This is my secret fedi account bio", is_discoverable: true)
|
||||
|
||||
assert "" = Pleroma.Web.Metadata.build_tags(%{user: user})
|
||||
end
|
||||
|
||||
test "search exclusion metadata is included" do
|
||||
clear_config([:instance, :public], false)
|
||||
user = insert(:user, bio: "This is my secret fedi account bio", is_discoverable: false)
|
||||
|
||||
assert ~s(<meta content="noindex, noarchive" name="robots">) ==
|
||||
Pleroma.Web.Metadata.build_tags(%{user: user})
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue