commit: 06f9324afeef813dbd299926000cb21076d5f41c
parent 837d4dc87f502c044414e4155c5401c13008047e
Author: Haelwenn <contact+git.pleroma.social@hacktivis.me>
Date: Fri, 12 Aug 2022 01:37:40 +0000
Merge branch 'from/upstream-develop/tusooa/2912-receiver-reject-mrf' into 'develop'
Treat MRF rejects as success in Oban worker
Closes #2912
See merge request pleroma/pleroma!3720
Diffstat:
3 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/lib/pleroma/workers/receiver_worker.ex b/lib/pleroma/workers/receiver_worker.ex
@@ -9,6 +9,12 @@ defmodule Pleroma.Workers.ReceiverWorker do
@impl Oban.Worker
def perform(%Job{args: %{"op" => "incoming_ap_doc", "params" => params}}) do
- Federator.perform(:incoming_ap_doc, params)
+ with {:ok, res} <- Federator.perform(:incoming_ap_doc, params) do
+ {:ok, res}
+ else
+ {:error, :origin_containment_failed} -> {:cancel, :origin_containment_failed}
+ {:error, {:reject, reason}} -> {:cancel, reason}
+ e -> e
+ end
end
end
diff --git a/test/pleroma/web/federator_test.exs b/test/pleroma/web/federator_test.exs
@@ -153,7 +153,7 @@ defmodule Pleroma.Web.FederatorTest do
}
assert {:ok, job} = Federator.incoming_ap_doc(params)
- assert {:error, :origin_containment_failed} = ObanHelpers.perform(job)
+ assert {:cancel, :origin_containment_failed} = ObanHelpers.perform(job)
end
test "it does not crash if MRF rejects the post" do
@@ -169,7 +169,7 @@ defmodule Pleroma.Web.FederatorTest do
|> Jason.decode!()
assert {:ok, job} = Federator.incoming_ap_doc(params)
- assert {:error, _} = ObanHelpers.perform(job)
+ assert {:cancel, _} = ObanHelpers.perform(job)
end
end
end
diff --git a/test/pleroma/workers/receiver_worker_test.exs b/test/pleroma/workers/receiver_worker_test.exs
@@ -0,0 +1,25 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Workers.ReceiverWorkerTest do
+ use Pleroma.DataCase, async: true
+ use Oban.Testing, repo: Pleroma.Repo
+
+ import Mock
+ import Pleroma.Factory
+
+ alias Pleroma.Workers.ReceiverWorker
+
+ test "it ignores MRF reject" do
+ params = insert(:note).data
+
+ with_mock Pleroma.Web.ActivityPub.Transmogrifier,
+ handle_incoming: fn _ -> {:reject, "MRF"} end do
+ assert {:cancel, "MRF"} =
+ ReceiverWorker.perform(%Oban.Job{
+ args: %{"op" => "incoming_ap_doc", "params" => params}
+ })
+ end
+ end
+end