mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-11-18 07:32:50 +00:00
Hide blocked users from interactions
This commit is contained in:
parent
a00aab3402
commit
a5d6287ba8
2 changed files with 44 additions and 2 deletions
|
@ -883,7 +883,10 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
||||||
with %Activity{data: %{"object" => object}} <- Activity.get_by_id(id),
|
with %Activity{data: %{"object" => object}} <- Activity.get_by_id(id),
|
||||||
%Object{data: %{"likes" => likes}} <- Object.normalize(object) do
|
%Object{data: %{"likes" => likes}} <- Object.normalize(object) do
|
||||||
q = from(u in User, where: u.ap_id in ^likes)
|
q = from(u in User, where: u.ap_id in ^likes)
|
||||||
users = Repo.all(q)
|
|
||||||
|
users =
|
||||||
|
Repo.all(q)
|
||||||
|
|> Enum.filter(&(not User.blocks?(user, &1)))
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> put_view(AccountView)
|
|> put_view(AccountView)
|
||||||
|
@ -897,7 +900,10 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
||||||
with %Activity{data: %{"object" => object}} <- Activity.get_by_id(id),
|
with %Activity{data: %{"object" => object}} <- Activity.get_by_id(id),
|
||||||
%Object{data: %{"announcements" => announces}} <- Object.normalize(object) do
|
%Object{data: %{"announcements" => announces}} <- Object.normalize(object) do
|
||||||
q = from(u in User, where: u.ap_id in ^announces)
|
q = from(u in User, where: u.ap_id in ^announces)
|
||||||
users = Repo.all(q)
|
|
||||||
|
users =
|
||||||
|
Repo.all(q)
|
||||||
|
|> Enum.filter(&(not User.blocks?(user, &1)))
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> put_view(AccountView)
|
|> put_view(AccountView)
|
||||||
|
|
|
@ -3768,6 +3768,24 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
||||||
|
|
||||||
assert Enum.empty?(response)
|
assert Enum.empty?(response)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "does not return users who have favorited the status but are blocked", %{
|
||||||
|
conn: %{assigns: %{user: user}} = conn,
|
||||||
|
activity: activity
|
||||||
|
} do
|
||||||
|
other_user = insert(:user)
|
||||||
|
{:ok, user} = User.block(user, other_user)
|
||||||
|
|
||||||
|
{:ok, _, _} = CommonAPI.favorite(activity.id, other_user)
|
||||||
|
|
||||||
|
response =
|
||||||
|
conn
|
||||||
|
|> assign(:user, user)
|
||||||
|
|> get("/api/v1/statuses/#{activity.id}/favourited_by")
|
||||||
|
|> json_response(:ok)
|
||||||
|
|
||||||
|
assert Enum.empty?(response)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET /api/v1/statuses/:id/reblogged_by" do
|
describe "GET /api/v1/statuses/:id/reblogged_by" do
|
||||||
|
@ -3807,6 +3825,24 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
||||||
|
|
||||||
assert Enum.empty?(response)
|
assert Enum.empty?(response)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "does not return users who have reblogged the status but are blocked", %{
|
||||||
|
conn: %{assigns: %{user: user}} = conn,
|
||||||
|
activity: activity
|
||||||
|
} do
|
||||||
|
other_user = insert(:user)
|
||||||
|
{:ok, user} = User.block(user, other_user)
|
||||||
|
|
||||||
|
{:ok, _, _} = CommonAPI.repeat(activity.id, other_user)
|
||||||
|
|
||||||
|
response =
|
||||||
|
conn
|
||||||
|
|> assign(:user, user)
|
||||||
|
|> get("/api/v1/statuses/#{activity.id}/reblogged_by")
|
||||||
|
|> json_response(:ok)
|
||||||
|
|
||||||
|
assert Enum.empty?(response)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "POST /auth/password, with valid parameters" do
|
describe "POST /auth/password, with valid parameters" do
|
||||||
|
|
Loading…
Reference in a new issue