Merge branch 'oban/deprecate-discards' into 'develop'

Oban: change :discard return values to :cancel

See merge request pleroma/pleroma!4175
This commit is contained in:
feld 2024-07-12 15:58:59 +00:00
commit 0ea63d824e
5 changed files with 12 additions and 12 deletions

View file

@ -123,9 +123,9 @@ def publish_one(%{inbox: inbox, json: json, actor: %User{} = actor, id: id} = pa
Logger.error("Publisher failed to inbox #{inbox} with status #{code}")
case response do
%{status: 403} -> {:discard, :forbidden}
%{status: 404} -> {:discard, :not_found}
%{status: 410} -> {:discard, :not_found}
%{status: 403} -> {:cancel, :forbidden}
%{status: 404} -> {:cancel, :not_found}
%{status: 410} -> {:cancel, :not_found}
_ -> {:error, e}
end

View file

@ -14,16 +14,16 @@ def perform(%Job{args: %{"op" => "fetch_remote", "id" => id} = args}) do
:ok
{:rejected, reason} ->
{:discard, reason}
{:cancel, reason}
{:error, :forbidden} ->
{:discard, :forbidden}
{:cancel, :forbidden}
{:error, :not_found} ->
{:discard, :not_found}
{:cancel, :not_found}
{:error, :allowed_depth} ->
{:discard, :allowed_depth}
{:cancel, :allowed_depth}
{:error, _} = e ->
e

View file

@ -223,7 +223,7 @@ test "publish to url with with different ports" do
actor = insert(:user)
inbox = "http://404.site/users/nick1/inbox"
assert {:discard, _} =
assert {:cancel, _} =
Publisher.publish_one(%{inbox: inbox, json: "{}", actor: actor, id: 1})
assert called(Instances.set_unreachable(inbox))

View file

@ -39,19 +39,19 @@ defmodule Pleroma.Workers.RemoteFetcherWorkerTest do
end
test "does not requeue a deleted object" do
assert {:discard, _} =
assert {:cancel, _} =
RemoteFetcherWorker.perform(%Oban.Job{
args: %{"op" => "fetch_remote", "id" => @deleted_object_one}
})
assert {:discard, _} =
assert {:cancel, _} =
RemoteFetcherWorker.perform(%Oban.Job{
args: %{"op" => "fetch_remote", "id" => @deleted_object_two}
})
end
test "does not requeue an unauthorized object" do
assert {:discard, _} =
assert {:cancel, _} =
RemoteFetcherWorker.perform(%Oban.Job{
args: %{"op" => "fetch_remote", "id" => @unauthorized_object}
})
@ -60,7 +60,7 @@ test "does not requeue an unauthorized object" do
test "does not requeue an object that exceeded depth" do
clear_config([:instance, :federation_incoming_replies_max_depth], 0)
assert {:discard, _} =
assert {:cancel, _} =
RemoteFetcherWorker.perform(%Oban.Job{
args: %{"op" => "fetch_remote", "id" => @depth_object, "depth" => 1}
})