Serialize lists as custom activitypub object
This commit is contained in:
@ -10,6 +10,7 @@ from .note import Note, GeneratedNote, Article, Comment, Review, Quotation
|
||||
from .note import Tombstone
|
||||
from .interaction import Boost, Like
|
||||
from .ordered_collection import OrderedCollection, OrderedCollectionPage
|
||||
from .ordered_collection import BookList
|
||||
from .person import Person, PublicKey
|
||||
from .response import ActivitypubResponse
|
||||
from .book import Edition, Work, Author
|
||||
|
@ -130,6 +130,7 @@ class ActivityObject:
|
||||
def serialize(self):
|
||||
''' convert to dictionary with context attr '''
|
||||
data = self.__dict__
|
||||
data = {k:v for (k, v) in data.items() if v is not None}
|
||||
data['@context'] = 'https://www.w3.org/ns/activitystreams'
|
||||
return data
|
||||
|
||||
|
@ -12,13 +12,20 @@ class OrderedCollection(ActivityObject):
|
||||
first: str
|
||||
last: str = None
|
||||
name: str = None
|
||||
summary: str = None
|
||||
owner: str = None
|
||||
to: List[str] = field(default_factory=lambda: [])
|
||||
cc: List[str] = field(default_factory=lambda: [])
|
||||
type: str = 'OrderedCollection'
|
||||
|
||||
|
||||
@dataclass(init=False)
|
||||
class BookList(OrderedCollection):
|
||||
''' structure of an ordered collection activity '''
|
||||
summary: str = None
|
||||
curation: str = 'closed'
|
||||
type: str = 'List'
|
||||
|
||||
|
||||
@dataclass(init=False)
|
||||
class OrderedCollectionPage(ActivityObject):
|
||||
''' structure of an ordered collection activity '''
|
||||
|
Reference in New Issue
Block a user