Skip to content

pg_fedi

Pure-SQL ActivityPub federation primitives for PostgreSQL and pg_tle environments.

pg_fedi · Pure-SQL ActivityPub federation primitives for PostgreSQL and pg_tle environments.

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
101908pg_fedipg_fedi0.2.0FEATApache-2.0SQL
Relationships
Requirespgcrypto

Usage

Sources:

pg_fedi Pure-SQL ActivityPub federation primitives for PostgreSQL and pg_tle environments.

Enablement

Install the files for the intended server, then create pg_fedi in the target database:

CREATE EXTENSION pg_fedi CASCADE;

The reviewed control or official workflow requires pgcrypto. CASCADE only succeeds when those extension files are already installed on the server.

Core Workflow

The following example is taken from the reviewed upstream documentation. Adapt object names, paths, credentials, and workload values before use.

-- Create a local actor (app layer generates RSA keypair, passes it in)
SELECT ap_create_local_actor('alice', 'Alice', 'Hello!', public_pem, private_pem);

-- Post a note (queues delivery to followers)
SELECT ap_create_note('alice', '<p>Hello, fediverse!</p>');

-- Process an inbound activity
SELECT ap_process_inbox_activity('{"type":"Follow", ...}'::jsonb);

-- WebFinger lookup
SELECT ap_webfinger('acct:alice@myinstance.social');

-- Actor profile as ActivityStreams JSON-LD
SELECT ap_serialize_actor('alice');

-- Timelines
SELECT * FROM ap_public_timeline;
SELECT * FROM ap_home_timeline('alice');

Main Objects

The reviewed install surface includes these prominent objects:

ObjectKindOperational role
ap_set_settingFUNCTIONCallable function from the reviewed install surface.
ap_process_inbox_activityFUNCTIONCallable function from the reviewed install surface.
ap_serialize_actorFUNCTIONCallable function from the reviewed install surface.
ap_webfingerFUNCTIONCallable function from the reviewed install surface.
ap_create_local_actorFUNCTIONCallable function from the reviewed install surface.
ap_create_noteFUNCTIONCallable function from the reviewed install surface.
ap_deliveriesTABLEExtension-owned table; account for its data in backup and upgrades.
ap_delivery_failureFUNCTIONCallable function from the reviewed install surface.

Operations and Boundaries

  • Treat extension upgrades as database changes: review the upstream upgrade path, privileges, locks, and backup/restore behavior first.

Table reader