Merge branch 'publisher' into 'develop'

Discard some failed publisher jobs

See merge request pleroma/pleroma!4022
This commit is contained in:
Haelwenn 2023-12-29 23:18:34 +00:00
commit f74f5e0a56
4 changed files with 20 additions and 4 deletions

View File

@ -0,0 +1 @@
Activity publishing failures will prevent the job from retrying if the publishing request returns a 403 or 410

View File

@ -0,0 +1 @@
Publisher errors will now emit logs indicating the inbox that was not available for delivery.

View File

@ -117,10 +117,23 @@ def publish_one(%{inbox: inbox, json: json, actor: %User{} = actor, id: id} = pa
result
else
{_post_result, response} = e ->
{_post_result, %{status: code} = response} = e ->
unless params[:unreachable_since], do: Instances.set_unreachable(inbox)
Logger.error("Failed to publish activity #{id} #{inspect(e)}")
{:error, response}
Logger.metadata(activity: id, inbox: inbox, status: code)
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}
_ -> {:error, e}
end
e ->
unless params[:unreachable_since], do: Instances.set_unreachable(inbox)
Logger.metadata(activity: id, inbox: inbox)
Logger.error("Publisher failed to inbox #{inbox} #{inspect(e)}")
{:error, e}
end
end

View File

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