Make mutes and blocks behave the same as other lists
This commit is contained in:
parent
29f4ab640b
commit
c1874bc8f9
2 changed files with 36 additions and 12 deletions
|
@ -491,7 +491,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
|
||||||
users =
|
users =
|
||||||
user
|
user
|
||||||
|> User.muted_users_relation(_restrict_deactivated = true)
|
|> User.muted_users_relation(_restrict_deactivated = true)
|
||||||
|> Pleroma.Pagination.fetch_paginated(Map.put(params, :skip_order, true))
|
|> Pleroma.Pagination.fetch_paginated(params)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> add_link_headers(users)
|
|> add_link_headers(users)
|
||||||
|
@ -508,7 +508,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
|
||||||
users =
|
users =
|
||||||
user
|
user
|
||||||
|> User.blocked_users_relation(_restrict_deactivated = true)
|
|> User.blocked_users_relation(_restrict_deactivated = true)
|
||||||
|> Pleroma.Pagination.fetch_paginated(Map.put(params, :skip_order, true))
|
|> Pleroma.Pagination.fetch_paginated(params)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> add_link_headers(users)
|
|> add_link_headers(users)
|
||||||
|
|
|
@ -1829,21 +1829,21 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
||||||
|> get("/api/v1/mutes")
|
|> get("/api/v1/mutes")
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
assert [id1, id2, id3] == Enum.map(result, & &1["id"])
|
assert [id3, id2, id1] == Enum.map(result, & &1["id"])
|
||||||
|
|
||||||
result =
|
result =
|
||||||
conn
|
conn
|
||||||
|> get("/api/v1/mutes?limit=1")
|
|> get("/api/v1/mutes?limit=1")
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
assert [%{"id" => ^id1}] = result
|
assert [%{"id" => ^id3}] = result
|
||||||
|
|
||||||
result =
|
result =
|
||||||
conn
|
conn
|
||||||
|> get("/api/v1/mutes?since_id=#{id1}")
|
|> get("/api/v1/mutes?since_id=#{id1}")
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
assert [%{"id" => ^id2}, %{"id" => ^id3}] = result
|
assert [%{"id" => ^id3}, %{"id" => ^id2}] = result
|
||||||
|
|
||||||
result =
|
result =
|
||||||
conn
|
conn
|
||||||
|
@ -1857,7 +1857,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
||||||
|> get("/api/v1/mutes?since_id=#{id1}&limit=1")
|
|> get("/api/v1/mutes?since_id=#{id1}&limit=1")
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
assert [%{"id" => ^id2}] = result
|
assert [%{"id" => ^id3}] = result
|
||||||
end
|
end
|
||||||
|
|
||||||
test "list of mutes with with_relationships parameter" do
|
test "list of mutes with with_relationships parameter" do
|
||||||
|
@ -1876,7 +1876,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
||||||
|
|
||||||
assert [
|
assert [
|
||||||
%{
|
%{
|
||||||
"id" => ^id1,
|
"id" => ^id3,
|
||||||
"pleroma" => %{"relationship" => %{"muting" => true, "followed_by" => true}}
|
"pleroma" => %{"relationship" => %{"muting" => true, "followed_by" => true}}
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
|
@ -1884,7 +1884,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
||||||
"pleroma" => %{"relationship" => %{"muting" => true, "followed_by" => true}}
|
"pleroma" => %{"relationship" => %{"muting" => true, "followed_by" => true}}
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
"id" => ^id3,
|
"id" => ^id1,
|
||||||
"pleroma" => %{"relationship" => %{"muting" => true, "followed_by" => true}}
|
"pleroma" => %{"relationship" => %{"muting" => true, "followed_by" => true}}
|
||||||
}
|
}
|
||||||
] =
|
] =
|
||||||
|
@ -1909,7 +1909,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
||||||
|> get("/api/v1/blocks")
|
|> get("/api/v1/blocks")
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
assert [id1, id2, id3] == Enum.map(result, & &1["id"])
|
assert [id3, id2, id1] == Enum.map(result, & &1["id"])
|
||||||
|
|
||||||
result =
|
result =
|
||||||
conn
|
conn
|
||||||
|
@ -1917,7 +1917,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
||||||
|> get("/api/v1/blocks?limit=1")
|
|> get("/api/v1/blocks?limit=1")
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
assert [%{"id" => ^id1}] = result
|
assert [%{"id" => ^id3}] = result
|
||||||
|
|
||||||
result =
|
result =
|
||||||
conn
|
conn
|
||||||
|
@ -1925,7 +1925,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
||||||
|> get("/api/v1/blocks?since_id=#{id1}")
|
|> get("/api/v1/blocks?since_id=#{id1}")
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
assert [%{"id" => ^id2}, %{"id" => ^id3}] = result
|
assert [%{"id" => ^id3}, %{"id" => ^id2}] = result
|
||||||
|
|
||||||
result =
|
result =
|
||||||
conn
|
conn
|
||||||
|
@ -1941,7 +1941,31 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
||||||
|> get("/api/v1/blocks?since_id=#{id1}&limit=1")
|
|> get("/api/v1/blocks?since_id=#{id1}&limit=1")
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
assert [%{"id" => ^id2}] = result
|
assert [%{"id" => ^id3}] = result
|
||||||
|
|
||||||
|
conn_res =
|
||||||
|
conn
|
||||||
|
|> assign(:user, user)
|
||||||
|
|> get("/api/v1/blocks?limit=2")
|
||||||
|
|
||||||
|
next_url =
|
||||||
|
~r{<.+?(?<link>/api[^>]+)>; rel=\"next\"}
|
||||||
|
|> Regex.named_captures(get_resp_header(conn_res, "link") |> Enum.at(0))
|
||||||
|
|> Map.get("link")
|
||||||
|
|
||||||
|
result =
|
||||||
|
conn_res
|
||||||
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
|
assert [%{"id" => ^id3}, %{"id" => ^id2}] = result
|
||||||
|
|
||||||
|
result =
|
||||||
|
conn
|
||||||
|
|> assign(:user, user)
|
||||||
|
|> get(next_url)
|
||||||
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
|
assert [%{"id" => ^id1}] = result
|
||||||
end
|
end
|
||||||
|
|
||||||
test "account lookup", %{conn: conn} do
|
test "account lookup", %{conn: conn} do
|
||||||
|
|
Loading…
Reference in a new issue