Treat MRF rejects as success in Oban worker
This commit is contained in:
parent
b2ba307f4d
commit
a0166e92fa
|
@ -9,6 +9,11 @@ defmodule Pleroma.Workers.ReceiverWorker do
|
||||||
|
|
||||||
@impl Oban.Worker
|
@impl Oban.Worker
|
||||||
def perform(%Job{args: %{"op" => "incoming_ap_doc", "params" => params}}) do
|
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, {:reject, reason}} -> {:cancel, reason}
|
||||||
|
e -> e
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue