bookwyrm/bookwyrm/activitypub/person.py
2023-11-08 16:00:10 -08:00

46 lines
1 KiB
Python

""" actor serializer """
from dataclasses import dataclass
from typing import Dict
from .base_activity import ActivityObject
from .image import Image
# pylint: disable=invalid-name
@dataclass(init=False)
class PublicKey(ActivityObject):
"""public key block"""
owner: str
publicKeyPem: str
type: str = "PublicKey"
def serialize(self, **kwargs):
"""remove fields"""
omit = ("type", "@context")
return super().serialize(omit=omit)
# pylint: disable=invalid-name
@dataclass(init=False)
class Person(ActivityObject):
"""actor activitypub json"""
preferredUsername: str
inbox: str
publicKey: PublicKey
followers: str = None
following: str = None
outbox: str = None
endpoints: Dict = None
name: str = None
summary: str = None
icon: Image = None
bookwyrmUser: bool = False
manuallyApprovesFollowers: str = False
discoverable: str = False
hideFollows: str = False
movedTo: str = None
alsoKnownAs: dict[str] = None
type: str = "Person"