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.Web.Federator.Publisher do
7 Defines the contract used by federation implementations to publish messages to
12 Determine whether an activity can be relayed using the federation module.
14 @callback is_representable?(Pleroma.Activity.t()) :: boolean()
17 Relays an activity to a specified peer, determined by the parameters. The
18 parameters used are controlled by the federation module.
20 @callback publish_one(Map.t()) :: {:ok, Map.t()} | {:error, any()}
23 Relays an activity to all specified peers.
25 @callback publish(Pleroma.User.t(), Pleroma.Activity.t()) :: :ok | {:error, any()}
28 Enqueues work generated by the federation module.
30 @spec enqueue(module(), keyword()) :: :ok
31 def enqueue(module, args), do: PleromaJobQueue.enqueue(:federation_outgoing, module, args)
34 Enqueue publishing a single activity.
36 @spec enqueue_one(module(), Map.t()) :: :ok
37 def enqueue_one(module, %{} = args), do: enqueue(module, [:publish_one, args])