1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Workers.Publisher do
9 # Note: `max_attempts` is intended to be overridden in `new/1` call
11 queue: "federator_outgoing",
12 max_attempts: Pleroma.Config.get([:workers, :retries, :compile_time_default])
15 def perform(%{"op" => "publish", "activity_id" => activity_id}) do
16 with %Activity{} = activity <- Activity.get_by_id(activity_id) do
17 perform_publish(activity)
19 _ -> raise "Non-existing activity: #{activity_id}"
23 def perform(%{"op" => "publish_one", "module" => module_name, "params" => params}) do
26 |> apply(:publish_one, [params])
29 def perform_publish(%Activity{} = activity) do
30 with %User{} = actor <- User.get_cached_by_ap_id(activity.data["actor"]),
31 {:ok, actor} <- User.ensure_keys_present(actor) do
32 Pleroma.Web.Federator.Publisher.publish(actor, activity)