View Source ActivityPub.Federator.Adapter behaviour (Bonfire v0.9.10-classic-beta.169)

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

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

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

Link to this callback

external_followers_for_activity(t, t)

View Source (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)

Link to this callback

get_actor_by_ap_id(ap_id)

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

Fetch an Actor by its full ActivityPub 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.

Link to this callback

get_actor_by_username(username)

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

Fetch an Actor given its preferred username

Link to this callback

get_follower_local_ids(t)

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

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

Link to this callback

get_following_local_ids(t)

View Source
@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.

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

Get the default locale of the host application.

Link to this callback

get_or_create_service_actor()

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

Creates an internal service actor by username, if missing.

@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.

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

Passes data to be handled by the host application

Link to this callback

maybe_create_remote_actor(t)

View Source
@callback maybe_create_remote_actor(ActivityPub.Actor.t()) :: :ok
Link to this callback

maybe_publish_object(t, t)

View Source
@callback maybe_publish_object(String.t(), Boolean.t()) :: {:ok, any()} | {:error, any()}
Link to this callback

update_local_actor(t, t)

View Source
@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.

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

Functions

Link to this function

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

View Source

Run function from adapter if defined, otherwise return fallback value

Link to this function

external_followers_for_activity(actor, activity)

View Source
Link to this function

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

View Source

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)

Link to this function

get_actor_by_username(username)

View Source
Link to this function

get_follower_local_ids(actor)

View Source
Link to this function

get_following_local_ids(actor)

View Source
Link to this function

get_or_create_service_actor()

View Source
Link to this function

get_redirect_url(id_or_username_or_object)

View Source
Link to this function

handle_activity(activity)

View Source
Link to this function

maybe_create_remote_actor(actor)

View Source
Link to this function

maybe_handle_activity(activity)

View Source
Link to this function

maybe_publish_object(object, manually_fetching? \\ false)

View Source
Link to this function

update_local_actor(actor, params)

View Source
Link to this function

update_remote_actor(actor)

View Source
Link to this function

update_remote_actor(actor, data)

View Source