bookwyrm-mastodon/bookwyrm/activitypub/__init__.py

32 lines
1.3 KiB
Python
Raw Permalink Normal View History

2021-03-08 11:49:10 -05:00
""" bring activitypub functions into the namespace """
import inspect
import sys
2021-02-15 20:23:17 -05:00
from .base_activity import ActivityEncoder, Signature, naive_parse
from .base_activity import Link, Mention
from .base_activity import ActivitySerializerError, resolve_remote_id
2021-04-17 14:47:48 -04:00
from .image import Document, Image
from .note import Note, GeneratedNote, Article, Comment, Quotation
from .note import Review, Rating
from .note import Tombstone
from .ordered_collection import OrderedCollection, OrderedCollectionPage
2021-04-08 17:16:34 -04:00
from .ordered_collection import CollectionItem, ListItem, ShelfItem
from .ordered_collection import BookList, Shelf
2020-11-30 13:32:13 -05:00
from .person import Person, PublicKey
from .response import ActivitypubResponse
from .book import Edition, Work, Author
2020-10-14 11:38:51 -04:00
from .verbs import Create, Delete, Undo, Update
2021-01-23 14:03:10 -05:00
from .verbs import Follow, Accept, Reject, Block
2021-02-23 18:51:02 -05:00
from .verbs import Add, Remove
2021-02-16 00:20:00 -05: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)
2021-03-08 11:49:10 -05:00
activity_objects = {c[0]: c[1] for c in cls_members if hasattr(c[1], "to_model")}
2021-02-15 20:23:17 -05:00
def parse(activity_json):
2021-04-26 12:15:42 -04:00
"""figure out what activity this is and parse it"""
2021-02-15 20:23:17 -05:00
return naive_parse(activity_objects, activity_json)