Do not federate undo->block activities
the :do_not_federate checks were omitted from the undo pipeline, which could lead to them federating. this commit enforces :outgoing_blocks on undos as well - and any existing value of :do_not_federate is preserved, if one exists Akkoma issue 957. [Pleroma: block/unblock test calls use the Pleroma (blocked, blocker) argument order.] (cherry picked from commit eca7ed572b8a10a0235fb1a381eac4803614dee4)
This commit is contained in:
parent
3e9dc477c9
commit
06612c802b
2 changed files with 26 additions and 0 deletions
|
|
@ -78,10 +78,16 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidator do
|
|||
|> Ecto.Changeset.apply_action(:insert) do
|
||||
object = stringify_keys(object)
|
||||
undone_object = Activity.get_by_ap_id(object["object"])
|
||||
outgoing_blocks = Pleroma.Config.get([:activitypub, :outgoing_blocks])
|
||||
# if we're undoing a block, and do not permit federating that:
|
||||
do_not_federate =
|
||||
Keyword.get(meta, :do_not_federate) ||
|
||||
(Map.get(undone_object.data, "type") == "Block" && !outgoing_blocks)
|
||||
|
||||
meta =
|
||||
meta
|
||||
|> Keyword.put(:object_data, undone_object.data)
|
||||
|> Keyword.put(:do_not_federate, do_not_federate)
|
||||
|
||||
{:ok, object, meta}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -338,6 +338,26 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
assert {:ok, :no_activity} == CommonAPI.unblock(blocked, blocker)
|
||||
refute User.blocks?(blocker, blocked)
|
||||
end
|
||||
|
||||
test "it unblocks and does not federate if outgoing blocks are disabled" do
|
||||
clear_config([:instance, :federating], true)
|
||||
clear_config([:activitypub, :outgoing_blocks], false)
|
||||
|
||||
blocked = insert(:user)
|
||||
blocker = insert(:user)
|
||||
|
||||
with_mock Pleroma.Web.Federator,
|
||||
publish: fn _ -> nil end do
|
||||
assert {:ok, block} = CommonAPI.block(blocked, blocker)
|
||||
assert block.local
|
||||
assert User.blocks?(blocker, blocked)
|
||||
|
||||
assert {:ok, unblock} = CommonAPI.unblock(blocked, blocker)
|
||||
assert unblock.local
|
||||
refute User.blocks?(blocker, blocked)
|
||||
assert_not_called(Pleroma.Web.Federator.publish(:_))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "deletion" do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue