bookwyrm-mastodon/bookwyrm/activitypub/person.py

44 lines
1.0 KiB
Python
Raw Normal View History

2021-03-08 11:49:10 -05:00
""" actor serializer """
from dataclasses import dataclass, field
from typing import Dict
2020-11-30 13:32:13 -05:00
from .base_activity import ActivityObject
2021-04-17 14:47:48 -04:00
from .image import Image
2020-11-30 13:32:13 -05:00
2021-06-18 17:29:24 -04:00
# pylint: disable=invalid-name
2020-11-30 13:32:13 -05:00
@dataclass(init=False)
class PublicKey(ActivityObject):
2021-04-26 12:15:42 -04:00
"""public key block"""
2021-03-08 11:49:10 -05:00
2020-11-30 13:32:13 -05:00
owner: str
publicKeyPem: str
2021-03-08 11:49:10 -05:00
type: str = "PublicKey"
2020-11-30 13:32:13 -05:00
2021-12-15 20:10:59 -05:00
def serialize(self, **kwargs):
"""remove fields"""
omit = ("type", "@context")
return super().serialize(omit=omit)
2020-11-30 13:32:13 -05:00
2021-06-18 17:29:24 -04:00
# pylint: disable=invalid-name
@dataclass(init=False)
class Person(ActivityObject):
2021-04-26 12:15:42 -04:00
"""actor activitypub json"""
2021-03-08 11:49:10 -05:00
preferredUsername: str
inbox: str
publicKey: PublicKey
2021-04-02 10:38:37 -04:00
followers: str = None
following: str = None
outbox: str = None
endpoints: Dict = None
name: str = None
summary: str = None
2021-04-17 14:47:48 -04:00
icon: Image = field(default_factory=lambda: {})
2020-10-31 16:06:22 -04:00
bookwyrmUser: bool = False
manuallyApprovesFollowers: str = False
discoverable: str = False
2022-02-28 14:48:49 -05:00
hideFollows: str = False
2021-03-08 11:49:10 -05:00
type: str = "Person"