Merge pull request 'Do not federate undo->block activities' (#958) from undo-block-federation into develop
Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/958 Reviewed-by: Oneric <oneric@noreply.akkoma>
This commit is contained in:
commit
2190f3bede
2 changed files with 26 additions and 0 deletions
|
|
@ -63,10 +63,16 @@ def validate(%{"type" => "Undo"} = object, meta) 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
|
||||
|
|
|
|||
|
|
@ -128,6 +128,26 @@ test "it works even without an existing block activity" do
|
|||
assert {:ok, :no_activity} == CommonAPI.unblock(blocker, blocked)
|
||||
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(blocker, blocked)
|
||||
assert block.local
|
||||
assert User.blocks?(blocker, blocked)
|
||||
|
||||
assert {:ok, unblock} = CommonAPI.unblock(blocker, blocked)
|
||||
assert unblock.local
|
||||
refute User.blocks?(blocker, blocked)
|
||||
assert_not_called(Pleroma.Web.Federator.publish(:_))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "deletion" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue