fix issue with API cascading domain blocks but not honouring them
This commit is contained in:
parent
5c164028cf
commit
c8e08e9cc3
2 changed files with 27 additions and 21 deletions
|
@ -1605,9 +1605,13 @@ defmodule Pleroma.User do
|
||||||
def blocks_user?(_, _), do: false
|
def blocks_user?(_, _), do: false
|
||||||
|
|
||||||
def blocks_domain?(%User{} = user, %User{} = target) do
|
def blocks_domain?(%User{} = user, %User{} = target) do
|
||||||
domain_blocks = Pleroma.Web.ActivityPub.MRF.subdomains_regex(user.domain_blocks)
|
|
||||||
%{host: host} = URI.parse(target.ap_id)
|
%{host: host} = URI.parse(target.ap_id)
|
||||||
Pleroma.Web.ActivityPub.MRF.subdomain_match?(domain_blocks, host)
|
Enum.member?(user.domain_blocks, host)
|
||||||
|
# TODO: functionality should probably be changed such that subdomains block as well,
|
||||||
|
# but as it stands, this just hecks up the relationships endpoint
|
||||||
|
# domain_blocks = Pleroma.Web.ActivityPub.MRF.subdomains_regex(user.domain_blocks)
|
||||||
|
# %{host: host} = URI.parse(target.ap_id)
|
||||||
|
# Pleroma.Web.ActivityPub.MRF.subdomain_match?(domain_blocks, host)
|
||||||
end
|
end
|
||||||
|
|
||||||
def blocks_domain?(_, _), do: false
|
def blocks_domain?(_, _), do: false
|
||||||
|
|
|
@ -1353,25 +1353,27 @@ defmodule Pleroma.UserTest do
|
||||||
refute User.blocks?(user, collateral_user)
|
refute User.blocks?(user, collateral_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "blocks domain with wildcard for subdomain" do
|
# This behaviour is not honoured by the timeline query
|
||||||
user = insert(:user)
|
# re-add at a later date when UX is established
|
||||||
|
# test "blocks domain with wildcard for subdomain" do
|
||||||
user_from_subdomain =
|
# user = insert(:user)
|
||||||
insert(:user, %{ap_id: "https://subdomain.awful-and-rude-instance.com/user/bully"})
|
#
|
||||||
|
# user_from_subdomain =
|
||||||
user_with_two_subdomains =
|
# insert(:user, %{ap_id: "https://subdomain.awful-and-rude-instance.com/user/bully"})
|
||||||
insert(:user, %{
|
#
|
||||||
ap_id: "https://subdomain.second_subdomain.awful-and-rude-instance.com/user/bully"
|
# user_with_two_subdomains =
|
||||||
})
|
# insert(:user, %{
|
||||||
|
# ap_id: "https://subdomain.second_subdomain.awful-and-rude-instance.com/user/bully"
|
||||||
user_domain = insert(:user, %{ap_id: "https://awful-and-rude-instance.com/user/bully"})
|
# })
|
||||||
|
#
|
||||||
{:ok, user} = User.block_domain(user, "awful-and-rude-instance.com")
|
# user_domain = insert(:user, %{ap_id: "https://awful-and-rude-instance.com/user/bully"})
|
||||||
|
#
|
||||||
assert User.blocks?(user, user_from_subdomain)
|
# {:ok, user} = User.block_domain(user, "awful-and-rude-instance.com")
|
||||||
assert User.blocks?(user, user_with_two_subdomains)
|
#
|
||||||
assert User.blocks?(user, user_domain)
|
# assert User.blocks?(user, user_from_subdomain)
|
||||||
end
|
# assert User.blocks?(user, user_with_two_subdomains)
|
||||||
|
# assert User.blocks?(user, user_domain)
|
||||||
|
# end
|
||||||
|
|
||||||
test "unblocks domains" do
|
test "unblocks domains" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
Loading…
Reference in a new issue