Merge pull request 'Stop exposing if a user blocks you over the API.' (#553) from XxXCertifiedForkliftDriverXxX/akkoma:feature/hide-blocked_by into develop

Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/553
This commit is contained in:
floatingghost 2023-05-28 22:02:33 +00:00
commit fb8081e1a3
4 changed files with 23 additions and 12 deletions

View file

@ -767,7 +767,7 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
"showing_reblogs" => true, "showing_reblogs" => true,
"followed_by" => true, "followed_by" => true,
"blocking" => false, "blocking" => false,
"blocked_by" => true, "blocked_by" => false,
"muting" => false, "muting" => false,
"muting_notifications" => false, "muting_notifications" => false,
"note" => "", "note" => "",
@ -783,7 +783,7 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
"showing_reblogs" => true, "showing_reblogs" => true,
"followed_by" => true, "followed_by" => true,
"blocking" => false, "blocking" => false,
"blocked_by" => true, "blocked_by" => false,
"muting" => true, "muting" => true,
"muting_notifications" => false, "muting_notifications" => false,
"note" => "", "note" => "",

View file

@ -13,7 +13,10 @@ defmodule Pleroma.Web.ApiSpec.Schemas.AccountRelationship do
description: "Relationship between current account and requested account", description: "Relationship between current account and requested account",
type: :object, type: :object,
properties: %{ properties: %{
blocked_by: %Schema{type: :boolean}, blocked_by: %Schema{
type: :boolean,
description: "Represents being blocked by this user. Always false."
},
blocking: %Schema{type: :boolean}, blocking: %Schema{type: :boolean},
domain_blocking: %Schema{type: :boolean}, domain_blocking: %Schema{type: :boolean},
endorsed: %Schema{type: :boolean}, endorsed: %Schema{type: :boolean},

View file

@ -124,14 +124,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
target, target,
&User.blocks_user?(&1, &2) &User.blocks_user?(&1, &2)
), ),
blocked_by: blocked_by: false,
UserRelationship.exists?(
user_relationships,
:block,
target,
reading_user,
&User.blocks_user?(&1, &2)
),
muting: muting:
UserRelationship.exists?( UserRelationship.exists?(
user_relationships, user_relationships,

View file

@ -397,7 +397,22 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
expected = expected =
Map.merge( Map.merge(
@blank_response, @blank_response,
%{following: false, blocking: true, blocked_by: true, id: to_string(other_user.id)} %{following: false, blocking: true, blocked_by: false, id: to_string(other_user.id)}
)
test_relationship_rendering(user, other_user, expected)
end
test "blocks are not visible to the blocked user" do
user = insert(:user)
other_user = insert(:user)
{:ok, _user_relationship} = User.block(other_user, user)
expected =
Map.merge(
@blank_response,
%{following: false, blocking: false, blocked_by: false, id: to_string(other_user.id)}
) )
test_relationship_rendering(user, other_user, expected) test_relationship_rendering(user, other_user, expected)