From 7c85b554cf7c24ed4468bc7b59f34ef3fa47abaa Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 17 Apr 2021 11:47:48 -0700 Subject: [PATCH] Handle both Image and Document types --- bookwyrm/activitypub/__init__.py | 2 +- bookwyrm/activitypub/image.py | 7 ++++++- bookwyrm/activitypub/person.py | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/bookwyrm/activitypub/__init__.py b/bookwyrm/activitypub/__init__.py index 71658455..d363fbd5 100644 --- a/bookwyrm/activitypub/__init__.py +++ b/bookwyrm/activitypub/__init__.py @@ -5,7 +5,7 @@ import sys from .base_activity import ActivityEncoder, Signature, naive_parse from .base_activity import Link, Mention from .base_activity import ActivitySerializerError, resolve_remote_id -from .image import Document +from .image import Document, Image from .note import Note, GeneratedNote, Article, Comment, Quotation from .note import Review, Rating from .note import Tombstone diff --git a/bookwyrm/activitypub/image.py b/bookwyrm/activitypub/image.py index 42598422..863388a7 100644 --- a/bookwyrm/activitypub/image.py +++ b/bookwyrm/activitypub/image.py @@ -5,9 +5,14 @@ from .base_activity import ActivityObject @dataclass(init=False) class Document(ActivityObject): - """ image block """ + """ a document """ url: str name: str = "" type: str = "Document" id: str = None + +@dataclass(init=False) +class Image(Document): + """ an image """ + type: str = "Image" diff --git a/bookwyrm/activitypub/person.py b/bookwyrm/activitypub/person.py index 550fc7bd..9231bd95 100644 --- a/bookwyrm/activitypub/person.py +++ b/bookwyrm/activitypub/person.py @@ -3,7 +3,7 @@ from dataclasses import dataclass, field from typing import Dict from .base_activity import ActivityObject -from .image import Document +from .image import Image @dataclass(init=False) @@ -28,7 +28,7 @@ class Person(ActivityObject): endpoints: Dict = None name: str = None summary: str = None - icon: Document = field(default_factory=lambda: {}) + icon: Image = field(default_factory=lambda: {}) bookwyrmUser: bool = False manuallyApprovesFollowers: str = False discoverable: str = False