Files
microblog.pub/little_boxes/README.md

38 lines
780 B
Markdown
Raw Normal View History

2018-06-09 10:15:52 +02:00
# Little Boxes
2018-06-10 13:51:43 +02:00
Tiny ActivityPub framework written in Python, both database and server agnostic.
2018-06-09 10:15:52 +02:00
## Getting Started
```python
2018-06-10 17:08:13 +02:00
from little_boxes import activitypub as ap
2018-06-09 10:15:52 +02:00
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)
2018-06-10 17:08:13 +02:00
ap.use_backend(my_backend)
2018-06-09 10:15:52 +02:00
2018-06-10 17:08:13 +02:00
me = ap.Person({}) # Init an actor
outbox = ap.Outbox(me)
2018-06-09 10:15:52 +02:00
2018-06-10 17:08:13 +02:00
follow = ap.Follow(actor=me, object='http://iri-i-want-follow')
2018-06-09 10:15:52 +02:00
outbox.post(follow)
```