Merge branch 'bugfix/streamer-follows' into 'develop'

streamer: use direct object for filter checks when there is no valid child object in an activity

Closes #1291

See merge request pleroma/pleroma!1931
This commit is contained in:
rinpatch 2019-11-03 17:09:57 +00:00
commit 8dd7c099a7
2 changed files with 19 additions and 1 deletions

View file

@ -136,7 +136,7 @@ defmodule Pleroma.Web.Streamer.Worker do
recipients = MapSet.new(item.recipients) recipients = MapSet.new(item.recipients)
domain_blocks = Pleroma.Web.ActivityPub.MRF.subdomains_regex(user.domain_blocks) domain_blocks = Pleroma.Web.ActivityPub.MRF.subdomains_regex(user.domain_blocks)
with parent when not is_nil(parent) <- Object.normalize(item), with parent <- Object.normalize(item) || item,
true <- Enum.all?([blocks, mutes, reblog_mutes], &(item.actor not in &1)), true <- Enum.all?([blocks, mutes, reblog_mutes], &(item.actor not in &1)),
true <- Enum.all?([blocks, mutes], &(parent.data["actor"] not in &1)), true <- Enum.all?([blocks, mutes], &(parent.data["actor"] not in &1)),
true <- MapSet.disjoint?(recipients, recipient_blocks), true <- MapSet.disjoint?(recipients, recipient_blocks),

View file

@ -110,6 +110,24 @@ defmodule Pleroma.Web.StreamerTest do
Streamer.stream("user:notification", notif) Streamer.stream("user:notification", notif)
Task.await(task) Task.await(task)
end end
test "it sends follow activities to the 'user:notification' stream", %{
user: user
} do
user2 = insert(:user)
task = Task.async(fn -> assert_receive {:text, _}, 4_000 end)
Streamer.add_socket(
"user:notification",
%{transport_pid: task.pid, assigns: %{user: user}}
)
{:ok, _follower, _followed, _activity} = CommonAPI.follow(user2, user)
# We don't directly pipe the notification to the streamer as it's already
# generated as a side effect of CommonAPI.follow().
Task.await(task)
end
end end
test "it sends to public" do test "it sends to public" do