Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel-dms
This commit is contained in:
commit
a8ca030d85
52 changed files with 4280 additions and 2682 deletions
|
|
@ -71,10 +71,48 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
get(conn, "/api/v2/search?q=天子")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert results["hashtags"] == [
|
||||
%{"name" => "天子", "url" => "#{Web.base_url()}/tag/天子"}
|
||||
]
|
||||
|
||||
[status] = results["statuses"]
|
||||
assert status["id"] == to_string(activity.id)
|
||||
end
|
||||
|
||||
test "constructs hashtags from search query", %{conn: conn} do
|
||||
results =
|
||||
conn
|
||||
|> get("/api/v2/search?#{URI.encode_query(%{q: "some text with #explicit #hashtags"})}")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert results["hashtags"] == [
|
||||
%{"name" => "explicit", "url" => "#{Web.base_url()}/tag/explicit"},
|
||||
%{"name" => "hashtags", "url" => "#{Web.base_url()}/tag/hashtags"}
|
||||
]
|
||||
|
||||
results =
|
||||
conn
|
||||
|> get("/api/v2/search?#{URI.encode_query(%{q: "john doe JOHN DOE"})}")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert results["hashtags"] == [
|
||||
%{"name" => "john", "url" => "#{Web.base_url()}/tag/john"},
|
||||
%{"name" => "doe", "url" => "#{Web.base_url()}/tag/doe"},
|
||||
%{"name" => "JohnDoe", "url" => "#{Web.base_url()}/tag/JohnDoe"}
|
||||
]
|
||||
|
||||
results =
|
||||
conn
|
||||
|> get("/api/v2/search?#{URI.encode_query(%{q: "accident-prone"})}")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert results["hashtags"] == [
|
||||
%{"name" => "accident", "url" => "#{Web.base_url()}/tag/accident"},
|
||||
%{"name" => "prone", "url" => "#{Web.base_url()}/tag/prone"},
|
||||
%{"name" => "AccidentProne", "url" => "#{Web.base_url()}/tag/AccidentProne"}
|
||||
]
|
||||
end
|
||||
|
||||
test "excludes a blocked users from search results", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
user_smith = insert(:user, %{nickname: "Agent", name: "I love 2hu"})
|
||||
|
|
@ -179,7 +217,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
[account | _] = results["accounts"]
|
||||
assert account["id"] == to_string(user_three.id)
|
||||
|
||||
assert results["hashtags"] == []
|
||||
assert results["hashtags"] == ["2hu"]
|
||||
|
||||
[status] = results["statuses"]
|
||||
assert status["id"] == to_string(activity.id)
|
||||
|
|
|
|||
|
|
@ -97,6 +97,49 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
res_conn = get(conn, "/api/v1/timelines/public")
|
||||
assert length(json_response_and_validate_schema(res_conn, 200)) == 1
|
||||
end
|
||||
|
||||
test "doesn't return replies if follower is posting with blocked user" do
|
||||
%{conn: conn, user: blocker} = oauth_access(["read:statuses"])
|
||||
[blockee, friend] = insert_list(2, :user)
|
||||
{:ok, blocker} = User.follow(blocker, friend)
|
||||
{:ok, _} = User.block(blocker, blockee)
|
||||
|
||||
conn = assign(conn, :user, blocker)
|
||||
|
||||
{:ok, %{id: activity_id} = activity} = CommonAPI.post(friend, %{status: "hey!"})
|
||||
|
||||
{:ok, reply_from_blockee} =
|
||||
CommonAPI.post(blockee, %{status: "heya", in_reply_to_status_id: activity})
|
||||
|
||||
{:ok, _reply_from_friend} =
|
||||
CommonAPI.post(friend, %{status: "status", in_reply_to_status_id: reply_from_blockee})
|
||||
|
||||
res_conn = get(conn, "/api/v1/timelines/public")
|
||||
[%{"id" => ^activity_id}] = json_response_and_validate_schema(res_conn, 200)
|
||||
end
|
||||
|
||||
test "doesn't return replies if follow is posting with users from blocked domain" do
|
||||
%{conn: conn, user: blocker} = oauth_access(["read:statuses"])
|
||||
friend = insert(:user)
|
||||
blockee = insert(:user, ap_id: "https://example.com/users/blocked")
|
||||
{:ok, blocker} = User.follow(blocker, friend)
|
||||
{:ok, blocker} = User.block_domain(blocker, "example.com")
|
||||
|
||||
conn = assign(conn, :user, blocker)
|
||||
|
||||
{:ok, %{id: activity_id} = activity} = CommonAPI.post(friend, %{status: "hey!"})
|
||||
|
||||
{:ok, reply_from_blockee} =
|
||||
CommonAPI.post(blockee, %{status: "heya", in_reply_to_status_id: activity})
|
||||
|
||||
{:ok, _reply_from_friend} =
|
||||
CommonAPI.post(friend, %{status: "status", in_reply_to_status_id: reply_from_blockee})
|
||||
|
||||
res_conn = get(conn, "/api/v1/timelines/public")
|
||||
|
||||
activities = json_response_and_validate_schema(res_conn, 200)
|
||||
[%{"id" => ^activity_id}] = activities
|
||||
end
|
||||
end
|
||||
|
||||
defp local_and_remote_activities do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue