microblog.pub/little_boxes
2018-06-10 17:08:13 +02:00
..
__init__.py [WIP] More work on the ActivityPub module 2018-06-08 21:33:46 +02:00
activitypub.py [WIP] Start tests for little_boxes 2018-06-10 16:58:25 +02:00
errors.py [WIP] More work on the ActivityPub module 2018-06-08 21:33:46 +02:00
README.md Tweak the README 2018-06-10 17:08:13 +02:00
urlutils.py [WIP] Start a new ActivityPub module 2018-06-07 00:00:35 +02:00
utils.py [WIP] Start an in-mem backend 2018-06-10 13:51:43 +02:00

Little Boxes

Tiny ActivityPub framework written in Python, both database and server agnostic.

Getting Started

from little_boxes import activitypub as ap

from mydb import db_client


class MyBackend(BaseBackend):

    def __init__(self, db_connection):
        self.db_connection = db_connection    

    def inbox_new(self, as_actor, activity):
        # Save activity as "as_actor"
        # [...]

    def post_to_remote_inbox(self, as_actor, payload, recipient):
        # Send the activity to the remote actor
        # [...]


db_con = db_client()
my_backend = MyBackend(db_con)

ap.use_backend(my_backend)

me = ap.Person({})  # Init an actor
outbox = ap.Outbox(me)

follow = ap.Follow(actor=me, object='http://iri-i-want-follow')
outbox.post(follow)