moviewyrm/bookwyrm/activitypub/__init__.py

30 lines
1.2 KiB
Python
Raw Normal View History

''' bring activitypub functions into the namespace '''
import inspect
import sys
2021-02-16 01:23:17 +00:00
from .base_activity import ActivityEncoder, Signature, naive_parse
from .base_activity import Link, Mention
from .base_activity import ActivitySerializerError, resolve_remote_id
2020-11-28 01:58:21 +00:00
from .image import Image
from .note import Note, GeneratedNote, Article, Comment, Review, Quotation
from .note import Tombstone
from .ordered_collection import OrderedCollection, OrderedCollectionPage
from .ordered_collection import BookList, Shelf
2020-11-30 18:32:13 +00:00
from .person import Person, PublicKey
from .response import ActivitypubResponse
from .book import Edition, Work, Author
2020-10-14 15:38:51 +00:00
from .verbs import Create, Delete, Undo, Update
2021-01-23 19:03:10 +00:00
from .verbs import Follow, Accept, Reject, Block
2021-02-19 19:16:01 +00:00
from .verbs import Add, AddListItem, Remove
2021-02-16 05:20:00 +00:00
from .verbs import Announce, Like
# this creates a list of all the Activity types that we can serialize,
# so when an Activity comes in from outside, we can check if it's known
cls_members = inspect.getmembers(sys.modules[__name__], inspect.isclass)
activity_objects = {c[0]: c[1] for c in cls_members \
if hasattr(c[1], 'to_model')}
2021-02-16 01:23:17 +00:00
def parse(activity_json):
''' figure out what activity this is and parse it '''
return naive_parse(activity_objects, activity_json)