akkoma/lib/pleroma/workers/publisher_worker.ex
Oneric 2b4b68eba7 Ensure private keys are not logged
Ideally we’d use a single common HTTP request error format handling
for _all_ HTTP requests (including non-ActivityPub requests, e.g. NodeInfo).
But for the purpose of this commit this would create too much noise
and it is significant effort to go through all error pattern matches etc
too ensure it is still all correct or update as needed.
2025-09-07 00:00:00 +00:00

50 lines
1.6 KiB
Elixir
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Pleroma: A lightweight social networking server
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Workers.PublisherWorker do
alias Pleroma.Activity
alias Pleroma.Web.Federator
use Pleroma.Workers.WorkerHelper, queue: "federator_outgoing"
def backoff(%Job{attempt: attempt}) when is_integer(attempt) do
if attempt > 3 do
Pleroma.Workers.WorkerHelper.exponential_backoff(attempt, 9.5)
else
Pleroma.Workers.WorkerHelper.sidekiq_backoff(attempt, 6)
end
end
@impl Oban.Worker
def perform(%Job{
args: %{"op" => "publish", "activity_id" => activity_id, "object_data" => nil}
}) do
activity = Activity.get_by_id(activity_id)
Federator.perform(:publish, activity)
end
@impl Oban.Worker
def perform(%Job{
args: %{"op" => "publish", "activity_id" => activity_id, "object_data" => object_data}
}) do
activity = Activity.get_by_id(activity_id)
activity = %{activity | data: Map.put(activity.data, "object", Jason.decode!(object_data))}
Federator.perform(:publish, activity)
end
def perform(%Job{args: %{"op" => "publish_one", "module" => module_name, "params" => params}}) do
res = Federator.perform(:publish_one, String.to_existing_atom(module_name), params)
case res do
# instance / actor was explicitly deleted; theres nothing to deliver to anymore
# since we dont know whether the whole instance is gone or just this actor,
# do NOT immediately mark the instance as unreachable
{:error, {:http_error, 410, _}} ->
:ok
res ->
res
end
end
end