2020-09-17 20:02:52 +00:00
|
|
|
''' note serializer and children thereof '''
|
|
|
|
from dataclasses import dataclass, field
|
|
|
|
from typing import Dict, List
|
|
|
|
|
2020-11-01 18:13:51 +00:00
|
|
|
from .base_activity import ActivityObject, Image, Link
|
2020-09-17 20:02:52 +00:00
|
|
|
|
2020-10-08 19:32:45 +00:00
|
|
|
@dataclass(init=False)
|
|
|
|
class Tombstone(ActivityObject):
|
2020-10-17 02:13:18 +00:00
|
|
|
''' the placeholder for a deleted status '''
|
2020-10-08 19:32:45 +00:00
|
|
|
url: str
|
|
|
|
published: str
|
|
|
|
deleted: str
|
|
|
|
type: str = 'Tombstone'
|
|
|
|
|
|
|
|
|
2020-09-17 20:02:52 +00:00
|
|
|
@dataclass(init=False)
|
|
|
|
class Note(ActivityObject):
|
|
|
|
''' Note activity '''
|
|
|
|
url: str
|
|
|
|
inReplyTo: str
|
|
|
|
published: str
|
|
|
|
attributedTo: str
|
|
|
|
to: List[str]
|
|
|
|
cc: List[str]
|
|
|
|
content: str
|
|
|
|
replies: Dict
|
2020-11-03 00:32:56 +00:00
|
|
|
tag: List[Link] = field(default=lambda: [])
|
2020-09-17 20:02:52 +00:00
|
|
|
attachment: List[Image] = field(default=lambda: [])
|
|
|
|
sensitive: bool = False
|
|
|
|
type: str = 'Note'
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(init=False)
|
|
|
|
class Article(Note):
|
|
|
|
''' what's an article except a note with more fields '''
|
|
|
|
name: str
|
|
|
|
type: str = 'Article'
|
|
|
|
|
|
|
|
|
2020-09-29 00:26:15 +00:00
|
|
|
@dataclass(init=False)
|
|
|
|
class GeneratedNote(Note):
|
|
|
|
''' just a re-typed note '''
|
2020-09-29 00:27:37 +00:00
|
|
|
type: str = 'GeneratedNote'
|
2020-09-29 00:26:15 +00:00
|
|
|
|
|
|
|
|
2020-09-17 20:02:52 +00:00
|
|
|
@dataclass(init=False)
|
|
|
|
class Comment(Note):
|
|
|
|
''' like a note but with a book '''
|
|
|
|
inReplyToBook: str
|
|
|
|
type: str = 'Comment'
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(init=False)
|
|
|
|
class Review(Comment):
|
|
|
|
''' a full book review '''
|
|
|
|
name: str
|
|
|
|
rating: int
|
|
|
|
type: str = 'Review'
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass(init=False)
|
|
|
|
class Quotation(Comment):
|
|
|
|
''' a quote and commentary on a book '''
|
|
|
|
quote: str
|
|
|
|
type: str = 'Quotation'
|