2021-03-08 11:49:10 -05:00
|
|
|
""" defines activitypub collections (lists) """
|
2021-02-02 12:37:46 -05:00
|
|
|
from dataclasses import dataclass, field
|
2020-09-17 16:02:52 -04:00
|
|
|
from typing import List
|
|
|
|
|
|
|
|
from .base_activity import ActivityObject
|
|
|
|
|
|
|
|
|
2021-06-18 17:29:24 -04:00
|
|
|
# pylint: disable=invalid-name
|
2020-09-17 16:02:52 -04:00
|
|
|
@dataclass(init=False)
|
|
|
|
class OrderedCollection(ActivityObject):
|
2021-04-26 12:15:42 -04:00
|
|
|
"""structure of an ordered collection activity"""
|
2021-03-08 11:49:10 -05:00
|
|
|
|
2020-09-17 16:02:52 -04:00
|
|
|
totalItems: int
|
|
|
|
first: str
|
2021-02-02 12:37:46 -05:00
|
|
|
last: str = None
|
|
|
|
name: str = None
|
|
|
|
owner: str = None
|
2021-03-08 11:49:10 -05:00
|
|
|
type: str = "OrderedCollection"
|
|
|
|
|
2021-02-02 14:17:31 -05:00
|
|
|
|
2021-06-18 17:29:24 -04:00
|
|
|
# pylint: disable=invalid-name
|
2021-02-02 14:17:31 -05:00
|
|
|
@dataclass(init=False)
|
|
|
|
class OrderedCollectionPrivate(OrderedCollection):
|
2021-04-26 12:15:42 -04:00
|
|
|
"""an ordered collection with privacy settings"""
|
2021-03-08 11:49:10 -05:00
|
|
|
|
2021-02-02 12:37:46 -05:00
|
|
|
to: List[str] = field(default_factory=lambda: [])
|
|
|
|
cc: List[str] = field(default_factory=lambda: [])
|
2020-09-17 16:02:52 -04:00
|
|
|
|
2021-03-08 11:49:10 -05:00
|
|
|
|
2021-02-02 14:17:31 -05:00
|
|
|
@dataclass(init=False)
|
|
|
|
class Shelf(OrderedCollectionPrivate):
|
2021-04-26 12:15:42 -04:00
|
|
|
"""structure of an ordered collection activity"""
|
2021-03-08 11:49:10 -05:00
|
|
|
|
|
|
|
type: str = "Shelf"
|
|
|
|
|
2020-09-17 16:02:52 -04:00
|
|
|
|
2021-02-02 14:05:47 -05:00
|
|
|
@dataclass(init=False)
|
2021-02-02 14:17:31 -05:00
|
|
|
class BookList(OrderedCollectionPrivate):
|
2021-04-26 12:15:42 -04:00
|
|
|
"""structure of an ordered collection activity"""
|
2021-03-08 11:49:10 -05:00
|
|
|
|
2021-02-02 14:05:47 -05:00
|
|
|
summary: str = None
|
2021-03-08 11:49:10 -05:00
|
|
|
curation: str = "closed"
|
|
|
|
type: str = "BookList"
|
2021-02-02 14:05:47 -05:00
|
|
|
|
|
|
|
|
2021-06-18 17:29:24 -04:00
|
|
|
# pylint: disable=invalid-name
|
2020-09-17 16:02:52 -04:00
|
|
|
@dataclass(init=False)
|
|
|
|
class OrderedCollectionPage(ActivityObject):
|
2021-04-26 12:15:42 -04:00
|
|
|
"""structure of an ordered collection activity"""
|
2021-03-08 11:49:10 -05:00
|
|
|
|
2020-09-17 16:02:52 -04:00
|
|
|
partOf: str
|
|
|
|
orderedItems: List
|
2021-02-17 16:33:48 -05:00
|
|
|
next: str = None
|
|
|
|
prev: str = None
|
2021-03-08 11:49:10 -05:00
|
|
|
type: str = "OrderedCollectionPage"
|
2021-04-08 17:16:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
@dataclass(init=False)
|
|
|
|
class CollectionItem(ActivityObject):
|
2021-04-26 12:15:42 -04:00
|
|
|
"""an item in a collection"""
|
2021-04-08 18:11:16 -04:00
|
|
|
|
2021-04-08 17:16:34 -04:00
|
|
|
actor: str
|
|
|
|
type: str = "CollectionItem"
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(init=False)
|
|
|
|
class ListItem(CollectionItem):
|
2021-04-26 12:15:42 -04:00
|
|
|
"""a book on a list"""
|
2021-04-08 18:11:16 -04:00
|
|
|
|
2021-04-08 17:16:34 -04:00
|
|
|
book: str
|
|
|
|
notes: str = None
|
|
|
|
approved: bool = True
|
|
|
|
order: int = None
|
|
|
|
type: str = "ListItem"
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(init=False)
|
|
|
|
class ShelfItem(CollectionItem):
|
2021-04-26 12:15:42 -04:00
|
|
|
"""a book on a list"""
|
2021-04-08 18:11:16 -04:00
|
|
|
|
2021-04-08 17:16:34 -04:00
|
|
|
book: str
|
|
|
|
type: str = "ShelfItem"
|