2020-02-17 23:12:19 -05:00
|
|
|
''' bring activitypub functions into the namespace '''
|
2020-09-17 16:02:52 -04:00
|
|
|
import inspect
|
|
|
|
import sys
|
|
|
|
|
2021-02-15 20:23:17 -05:00
|
|
|
from .base_activity import ActivityEncoder, Signature, naive_parse
|
2020-11-01 13:13:51 -05:00
|
|
|
from .base_activity import Link, Mention
|
2020-11-28 13:18:24 -05:00
|
|
|
from .base_activity import ActivitySerializerError, resolve_remote_id
|
2020-11-27 20:58:21 -05:00
|
|
|
from .image import Image
|
2020-09-28 20:26:15 -04:00
|
|
|
from .note import Note, GeneratedNote, Article, Comment, Review, Quotation
|
2020-11-01 13:13:51 -05:00
|
|
|
from .note import Tombstone
|
2020-09-17 16:02:52 -04:00
|
|
|
from .interaction import Boost, Like
|
|
|
|
from .ordered_collection import OrderedCollection, OrderedCollectionPage
|
2021-02-02 14:17:31 -05:00
|
|
|
from .ordered_collection import BookList, Shelf
|
2020-11-30 13:32:13 -05:00
|
|
|
from .person import Person, PublicKey
|
2020-12-30 05:12:04 -05:00
|
|
|
from .response import ActivitypubResponse
|
2020-09-17 16:02:52 -04:00
|
|
|
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-10 22:17:01 -05:00
|
|
|
from .verbs import Add, AddBook, AddListItem, Remove
|
2020-09-17 16:02:52 -04:00
|
|
|
|
|
|
|
# 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-15 20:23:17 -05:00
|
|
|
|
|
|
|
def parse(activity_json):
|
|
|
|
''' figure out what activity this is and parse it '''
|
|
|
|
return naive_parse(activity_objects, activity_json)
|