Merge branch 'oban/more-improvements' into 'develop'

Oban: more improvements

See merge request pleroma/pleroma!4187
This commit is contained in:
feld 2024-07-22 17:45:44 +00:00
commit f77911f05b
12 changed files with 18 additions and 9 deletions

View file

@ -0,0 +1 @@
Publisher jobs will not retry if the error received is a 400

View file

@ -0,0 +1 @@
PollWorker jobs will not retry if the activity no longer exists.

View file

@ -0,0 +1 @@
Improved detecting unrecoverable errors for incoming federation jobs

View file

View file

@ -123,6 +123,7 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
Logger.error("Publisher failed to inbox #{inbox} with status #{code}") Logger.error("Publisher failed to inbox #{inbox} with status #{code}")
case response do case response do
%{status: 400} -> {:cancel, :bad_request}
%{status: 403} -> {:cancel, :forbidden} %{status: 403} -> {:cancel, :forbidden}
%{status: 404} -> {:cancel, :not_found} %{status: 404} -> {:cancel, :not_found}
%{status: 410} -> {:cancel, :not_found} %{status: 410} -> {:cancel, :not_found}

View file

@ -453,7 +453,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
) do ) do
orig_object_ap_id = updated_object["id"] orig_object_ap_id = updated_object["id"]
orig_object = Object.get_by_ap_id(orig_object_ap_id) orig_object = Object.get_by_ap_id(orig_object_ap_id)
orig_object_data = orig_object.data orig_object_data = Map.get(orig_object, :data)
updated_object = updated_object =
if meta[:local] do if meta[:local] do

View file

@ -40,5 +40,5 @@ defmodule Pleroma.Workers.BackgroundWorker do
end end
@impl Oban.Worker @impl Oban.Worker
def timeout(_job), do: :timer.seconds(5) def timeout(_job), do: :timer.seconds(15)
end end

View file

@ -17,6 +17,9 @@ defmodule Pleroma.Workers.PollWorker do
with %Activity{} = activity <- find_poll_activity(activity_id), with %Activity{} = activity <- find_poll_activity(activity_id),
{:ok, notifications} <- Notification.create_poll_notifications(activity) do {:ok, notifications} <- Notification.create_poll_notifications(activity) do
Notification.stream(notifications) Notification.stream(notifications)
else
{:error, :poll_activity_not_found} = e -> {:cancel, e}
e -> {:error, e}
end end
end end

View file

@ -47,11 +47,13 @@ defmodule Pleroma.Workers.ReceiverWorker do
case errors do case errors do
{:error, :origin_containment_failed} -> {:cancel, :origin_containment_failed} {:error, :origin_containment_failed} -> {:cancel, :origin_containment_failed}
{:error, :already_present} -> {:cancel, :already_present} {:error, :already_present} -> {:cancel, :already_present}
{:error, {:validate_object, reason}} -> {:cancel, reason} {:error, {:validate_object, _} = reason} -> {:cancel, reason}
{:error, {:error, {:validate, reason}}} -> {:cancel, reason} {:error, {:error, {:validate, {:error, _changeset} = reason}}} -> {:cancel, reason}
{:error, {:reject, reason}} -> {:cancel, reason} {:error, {:reject, _} = reason} -> {:cancel, reason}
{:signature, false} -> {:cancel, :invalid_signature} {:signature, false} -> {:cancel, :invalid_signature}
{:error, {:error, reason = "Object has been deleted"}} -> {:cancel, reason} {:error, "Object has been deleted"} = reason -> {:cancel, reason}
{:error, {:side_effects, {:error, :no_object_actor}} = reason} -> {:cancel, reason}
{:error, :not_found} = reason -> {:cancel, reason}
{:error, _} = e -> e {:error, _} = e -> e
e -> {:error, e} e -> {:error, e}
end end

View file

@ -31,5 +31,5 @@ defmodule Pleroma.Workers.RemoteFetcherWorker do
end end
@impl Oban.Worker @impl Oban.Worker
def timeout(_job), do: :timer.seconds(10) def timeout(_job), do: :timer.seconds(15)
end end

View file

@ -13,5 +13,5 @@ defmodule Pleroma.Workers.UserRefreshWorker do
end end
@impl Oban.Worker @impl Oban.Worker
def timeout(_job), do: :timer.seconds(5) def timeout(_job), do: :timer.seconds(15)
end end

View file

@ -16,7 +16,7 @@ defmodule Pleroma.Workers.ReceiverWorkerTest do
with_mock Pleroma.Web.ActivityPub.Transmogrifier, with_mock Pleroma.Web.ActivityPub.Transmogrifier,
handle_incoming: fn _ -> {:reject, "MRF"} end do handle_incoming: fn _ -> {:reject, "MRF"} end do
assert {:cancel, "MRF"} = assert {:cancel, {:reject, "MRF"}} =
ReceiverWorker.perform(%Oban.Job{ ReceiverWorker.perform(%Oban.Job{
args: %{"op" => "incoming_ap_doc", "params" => params} args: %{"op" => "incoming_ap_doc", "params" => params}
}) })