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 Actor
s following the given Actor
.
Get the host application IDs for all Actor
s 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
.
Functions
Run function from adapter if defined, otherwise return fallback value
Whether this (local or remote) actor has federation enabled and/or is blocked on this instance
Callbacks
@callback base_url() :: String.t()
The base URL of the application serving ActivityPub.Web.Endpoint
.
@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)
@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.
@callback get_actor_by_username(ActivityPub.Actor.username()) :: {:ok, ActivityPub.Actor.t()} | {:error, any()}
Fetch an Actor
given its preferred username
@callback get_follower_local_ids(ActivityPub.Actor.t()) :: [ActivityPub.Actor.id()]
Get the host application IDs for all Actor
s following the given Actor
.
@callback get_following_local_ids(ActivityPub.Actor.t()) :: [ActivityPub.Actor.id()]
Get the host application IDs for all Actor
s that the given Actor
is following.
@callback get_locale() :: String.t()
Get the default locale of the host application.
@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
@callback maybe_create_remote_actor(ActivityPub.Actor.t()) :: :ok
@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
Run function from adapter if defined, otherwise return fallback value
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)