1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Workers.PublisherWorker do
7 alias Pleroma.Web.Federator
9 use Pleroma.Workers.WorkerHelper, queue: "federator_outgoing"
11 def backoff(%Job{attempt: attempt}) when is_integer(attempt) do
12 Pleroma.Workers.WorkerHelper.sidekiq_backoff(attempt, 5)
16 def perform(%Job{args: %{"op" => "publish", "activity_id" => activity_id}}) do
17 activity = Activity.get_by_id(activity_id)
18 Federator.perform(:publish, activity)
21 def perform(%Job{args: %{"op" => "publish_one", "params" => params}}) do
22 params = Map.new(params, fn {k, v} -> {String.to_atom(k), v} end)
23 Federator.perform(:publish_one, params)
27 def timeout(_job), do: :timer.seconds(10)