View Source ActivityPub.Federator.Adapter behaviour (Bonfire v0.9.11-social-beta.6)

Contract for ActivityPub module adapters

Summary

Callbacks

The base URL of the application serving ActivityPub.Web.Endpoint.

Compute and return a subset of followers that should receive a specific activity (optional)

Fetch an Actor by its full ActivityPub ID.

Fetch an Actor by its ID in the host application database.

Fetch an Actor given its preferred username

Get the host application IDs for all Actors following the given Actor.

Get the host application IDs for all Actors that the given Actor is following.

Get the default locale of the host application.

Creates an internal service actor by username, if missing.

Gets local url of an AP object to redirect in browser. Can take pointer id or an actor username.

Passes data to be handled by the host application

Commit new fields to the host application database for the given Actor.

Callbacks

base_url()

@callback base_url() :: String.t()

The base URL of the application serving ActivityPub.Web.Endpoint.

external_followers_for_activity(t, t)

(optional)
@callback external_followers_for_activity(List.t(), Map.t()) :: List.t()

Compute and return a subset of followers that should receive a specific activity (optional)

get_actor_by_ap_id(ap_id)

@callback get_actor_by_ap_id(ActivityPub.Actor.ap_id()) ::
  {:ok, ActivityPub.Actor.t()} | {:error, any()}

Fetch an Actor by its full ActivityPub ID.

get_actor_by_id(id)

@callback get_actor_by_id(ActivityPub.Actor.id()) ::
  {:ok, ActivityPub.Actor.t()} | {:error, any()}

Fetch an Actor by its ID in the host application database.

get_actor_by_username(username)

@callback get_actor_by_username(ActivityPub.Actor.username()) ::
  {:ok, ActivityPub.Actor.t()} | {:error, any()}

Fetch an Actor given its preferred username

get_follower_local_ids(t)

@callback get_follower_local_ids(ActivityPub.Actor.t()) :: [ActivityPub.Actor.id()]

Get the host application IDs for all Actors following the given Actor.

get_following_local_ids(t)

@callback get_following_local_ids(ActivityPub.Actor.t()) :: [ActivityPub.Actor.id()]

Get the host application IDs for all Actors that the given Actor is following.

get_locale()

@callback get_locale() :: String.t()

Get the default locale of the host application.

get_or_create_service_actor()

@callback get_or_create_service_actor() :: ActivityPub.Actor.t() | nil

Creates an internal service actor by username, if missing.

get_redirect_url(arg1)

@callback get_redirect_url(ActivityPub.Actor.username() | Map.t()) :: String.t()

Gets local url of an AP object to redirect in browser. Can take pointer id or an actor username.

handle_activity(t)

@callback handle_activity(ActivityPub.Object.t()) :: :ok | {:ok, any()} | {:error, any()}

Passes data to be handled by the host application

maybe_create_remote_actor(t)

@callback maybe_create_remote_actor(ActivityPub.Actor.t()) :: :ok

maybe_publish_object(t, t)

@callback maybe_publish_object(String.t(), Boolean.t()) :: {:ok, any()} | {:error, any()}

update_local_actor(t, t)

@callback update_local_actor(ActivityPub.Actor.t(), Map.t()) ::
  {:ok, ActivityPub.Actor.t()} | {:error, any()}

Commit new fields to the host application database for the given Actor.

update_remote_actor(t)

@callback update_remote_actor(ActivityPub.Object.t()) :: :ok | {:error, any()}

Functions

adapter()

base_url()

call_or(fun, args \\ [], fallback \\ nil)

Run function from adapter if defined, otherwise return fallback value

external_followers_for_activity(actor, activity)

federate_actor?(actor, direction \\ nil, by_actor \\ nil)

Whether this (local or remote) actor has federation enabled and/or is blocked on this instance

actor: the actor to check (eg. Alice) direction: :in or :out - whether we're dealing with incoming federation or outgoing (optional) by_actor: optionally another actor (eg. if Alice is sending something to Bob, this would be Bob)

get_actor_by_ap_id(id)

get_actor_by_id(id)

get_actor_by_username(username)

get_follower_local_ids(actor)

get_following_local_ids(actor)

get_locale()

get_or_create_service_actor()

get_redirect_url(id_or_username_or_object)

handle_activity(activity)

maybe_create_remote_actor(actor)

maybe_handle_activity(activity)

maybe_publish_object(object, manually_fetching? \\ false)

update_local_actor(actor, params)

update_remote_actor(actor)

update_remote_actor(actor, data)