Merge pull request 'Search: fetch remote statuses only when resolving is allowed' (#8031) from lambadalambda/pleroma:fix/search-remote-fetch into develop
Reviewed-on: https://git.pleroma.social/pleroma/pleroma/pulls/8031
This commit is contained in:
commit
240bc1be1f
7 changed files with 62 additions and 15 deletions
|
|
@ -328,7 +328,9 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
assert status["id"] == to_string(activity.id)
|
||||
end
|
||||
|
||||
test "search fetches remote statuses and prefers them over other results", %{conn: conn} do
|
||||
test "search fetches remote statuses and prefers them over other results" do
|
||||
%{conn: conn} = oauth_access(["read:search"])
|
||||
|
||||
{:ok, %{id: activity_id}} =
|
||||
CommonAPI.post(insert(:user), %{
|
||||
status: "check out http://mastodon.example.org/@admin/99541947525187367"
|
||||
|
|
@ -336,7 +338,9 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
|
||||
%{"url" => result_url, "id" => result_id} =
|
||||
conn
|
||||
|> get("/api/v1/search?q=http://mastodon.example.org/@admin/99541947525187367")
|
||||
|> get(
|
||||
"/api/v1/search?resolve=true&q=http://mastodon.example.org/@admin/99541947525187367"
|
||||
)
|
||||
|> json_response_and_validate_schema(200)
|
||||
|> Map.get("statuses")
|
||||
|> List.first()
|
||||
|
|
@ -345,6 +349,28 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
assert match?(^result_url, "http://mastodon.example.org/@admin/99541947525187367")
|
||||
end
|
||||
|
||||
test "search fetches remote statuses only with resolve, when logged in, on the first page",
|
||||
%{conn: anonymous} do
|
||||
%{conn: conn} = oauth_access(["read:search"])
|
||||
url = "http://mastodon.example.org/@admin/99541947525187367"
|
||||
|
||||
for {conn, params} <- [
|
||||
{conn, ""},
|
||||
{conn, "&resolve=false"},
|
||||
{conn, "&resolve=true&offset=5"},
|
||||
{anonymous, "&resolve=true"}
|
||||
] do
|
||||
assert %{"statuses" => []} =
|
||||
conn
|
||||
|> get("/api/v1/search?q=#{url}#{params}")
|
||||
|> json_response_and_validate_schema(200)
|
||||
end
|
||||
|
||||
refute Pleroma.Object.get_by_ap_id(
|
||||
"http://mastodon.example.org/users/admin/statuses/99541947525187367"
|
||||
)
|
||||
end
|
||||
|
||||
test "search doesn't show statuses that it shouldn't", %{conn: conn} do
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(insert(:user), %{
|
||||
|
|
|
|||
|
|
@ -788,7 +788,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
|
||||
test "put the url advertised in the Activity in to the url attribute" do
|
||||
id = "https://wedistribute.org/wp-json/pterotype/v1/object/85810"
|
||||
[activity] = Activity.search(nil, id)
|
||||
[activity] = Activity.search(insert(:user), id, resolve: true)
|
||||
|
||||
status = StatusView.render("show.json", %{activity: activity})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue