From 868723e371ba12f74dcd68828ea6fba15c0456f6 Mon Sep 17 00:00:00 2001 From: Lain Soykaf Date: Fri, 24 Jul 2026 16:01:46 +0400 Subject: [PATCH] fix(streaming): preserve followed domain exception --- changelog.d/stream-domain-block-following.fix | 1 + lib/pleroma/web/streamer.ex | 11 +++++++++-- test/pleroma/web/streamer_test.exs | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 changelog.d/stream-domain-block-following.fix diff --git a/changelog.d/stream-domain-block-following.fix b/changelog.d/stream-domain-block-following.fix new file mode 100644 index 000000000..84890c680 --- /dev/null +++ b/changelog.d/stream-domain-block-following.fix @@ -0,0 +1 @@ +Keep followed users visible in streams when their domain is blocked. diff --git a/lib/pleroma/web/streamer.ex b/lib/pleroma/web/streamer.ex index 120e94751..5abe33af1 100644 --- a/lib/pleroma/web/streamer.ex +++ b/lib/pleroma/web/streamer.ex @@ -195,6 +195,9 @@ defmodule Pleroma.Web.Streamer do recipients = MapSet.new(item.recipients) domain_blocks = Pleroma.Web.ActivityPub.MRF.subdomains_regex(user.domain_blocks) + following_ap_ids = + if user.domain_blocks == [], do: [], else: User.get_cached_user_friends_ap_ids(user) + with parent <- Object.normalize(item, fetch: false) || item, true <- Enum.all?([blocked_ap_ids, muted_ap_ids], &(item.actor not in &1)), true <- item.data["type"] != "Announce" || item.actor not in reblog_muted_ap_ids, @@ -205,8 +208,12 @@ defmodule Pleroma.Web.Streamer do true <- MapSet.disjoint?(recipients, recipient_blocks), %{host: item_host} <- URI.parse(item.actor), %{host: parent_host} <- URI.parse(parent.data["actor"]), - false <- Pleroma.Web.ActivityPub.MRF.subdomain_match?(domain_blocks, item_host), - false <- Pleroma.Web.ActivityPub.MRF.subdomain_match?(domain_blocks, parent_host), + false <- + item.actor not in following_ap_ids and + Pleroma.Web.ActivityPub.MRF.subdomain_match?(domain_blocks, item_host), + false <- + parent.data["actor"] not in following_ap_ids and + Pleroma.Web.ActivityPub.MRF.subdomain_match?(domain_blocks, parent_host), true <- thread_containment(item, user), false <- CommonAPI.thread_muted?(parent, user) do false diff --git a/test/pleroma/web/streamer_test.exs b/test/pleroma/web/streamer_test.exs index b26bd1847..7610b3379 100644 --- a/test/pleroma/web/streamer_test.exs +++ b/test/pleroma/web/streamer_test.exs @@ -475,6 +475,20 @@ defmodule Pleroma.Web.StreamerTest do assert Streamer.filtered_by_user?(user, favorite_activity) end + test "it does not filter followed users on blocked domains", %{user: user} do + followed = + insert(:user, %{ap_id: "https://hecking-lewd-place.com/user/friend"}) + + {:ok, user} = User.block_domain(user, "hecking-lewd-place.com") + {:ok, activity} = CommonAPI.post(followed, %{status: "still a friend"}) + + assert Streamer.filtered_by_user?(user, activity) + + {:ok, user, _followed} = User.follow(user, followed) + + refute Streamer.filtered_by_user?(user, activity) + end + test "it sends follow activities to the 'user:notification' stream", %{ user: user, token: oauth_token