Skip to content

Combining bovine_herd with mechanical_bull

Bovine is meant as a framework to build Fediverse applications. Thus certain choices have been pushed to the end. It is thus non trivial to set up a server. In this tutorial, we will illustrate how to do it.

Installing stuff

One can install the necessary packages used for this tutorial via

pip install bovine-herd bovine-tool bovine-pubsub mechanical-bull

You will furthermore need a domain to run everything on. In this tutorial, we will just use localhost specified below as http://localhost:3333. This is necessary as endpoints and objects are stored by their URIs, so in this case something starting with http://localhost:3333.

Creating the database and registering a user

By using the package bovine_tool, one can create the databse via

python -mbovine_tool.create

This will create the file bovine.sqlite3. We can new register a new user with

python -mbovine_tool.register --domain http://localhost:3333 $YOUR_USERNAME

Bovine name: ${YOUR_USERNAME}_617bad0d-8907-4919-861d-a32ca2389cce

You can now inspect the generated endpoints by running

sqlite3 bovine.sqlite3 'select * from bovineactorendpoint'

The bovine name will be used to identify your user. Next, we can create a mechanical bull configuration file via

python -mmechanical_bull.add_user $YOUR_USERNAME http://localhost:3333 --accept 

Adding new user to config.toml
Please add did:key:z6MkpgFCGTrk3dayGUGNx5dV1ohCMKectVPvduheddzu7LCV to the access list of your ActivityPub actor

Then we can add this did key to our user via

python -mbovine_tool.manage $BOVINE_NAME --did_key bull $DID_KEY

The task of mechanical bull here is to automatically accept follow requests.

Running bovine

app.py
import logging
from quart import Quart

from bovine_pubsub import BovinePubSub
from bovine_herd import BovineHerd
from mechanical_bull.run import mechanical_bull

logging.basicConfig(level=logging.INFO)

app = Quart(__name__)


@app.while_serving
async def bull():
    app.add_background_task(mechanical_bull, "config.toml")
    yield


BovinePubSub(app)
BovineHerd(app)

We can now run the server via

hypercorn app:app -b localhost:3333