mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-14 20:26:32 +00:00
Merge branch 'main' into production
This commit is contained in:
commit
107d56c494
8 changed files with 21 additions and 20 deletions
|
@ -5,7 +5,7 @@ import sys
|
||||||
from .base_activity import ActivityEncoder, Signature, naive_parse
|
from .base_activity import ActivityEncoder, Signature, naive_parse
|
||||||
from .base_activity import Link, Mention
|
from .base_activity import Link, Mention
|
||||||
from .base_activity import ActivitySerializerError, resolve_remote_id
|
from .base_activity import ActivitySerializerError, resolve_remote_id
|
||||||
from .image import Image
|
from .image import Document
|
||||||
from .note import Note, GeneratedNote, Article, Comment, Quotation
|
from .note import Note, GeneratedNote, Article, Comment, Quotation
|
||||||
from .note import Review, Rating
|
from .note import Review, Rating
|
||||||
from .note import Tombstone
|
from .note import Tombstone
|
||||||
|
|
|
@ -3,7 +3,7 @@ from dataclasses import dataclass, field
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from .base_activity import ActivityObject
|
from .base_activity import ActivityObject
|
||||||
from .image import Image
|
from .image import Document
|
||||||
|
|
||||||
|
|
||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
|
@ -28,7 +28,7 @@ class Book(ActivityObject):
|
||||||
librarythingKey: str = ""
|
librarythingKey: str = ""
|
||||||
goodreadsKey: str = ""
|
goodreadsKey: str = ""
|
||||||
|
|
||||||
cover: Image = None
|
cover: Document = None
|
||||||
type: str = "Book"
|
type: str = "Book"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ from .base_activity import ActivityObject
|
||||||
|
|
||||||
|
|
||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
class Image(ActivityObject):
|
class Document(ActivityObject):
|
||||||
""" image block """
|
""" image block """
|
||||||
|
|
||||||
url: str
|
url: str
|
||||||
|
|
|
@ -4,7 +4,7 @@ from typing import Dict, List
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
|
|
||||||
from .base_activity import ActivityObject, Link
|
from .base_activity import ActivityObject, Link
|
||||||
from .image import Image
|
from .image import Document
|
||||||
|
|
||||||
|
|
||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
|
@ -32,7 +32,7 @@ class Note(ActivityObject):
|
||||||
inReplyTo: str = ""
|
inReplyTo: str = ""
|
||||||
summary: str = ""
|
summary: str = ""
|
||||||
tag: List[Link] = field(default_factory=lambda: [])
|
tag: List[Link] = field(default_factory=lambda: [])
|
||||||
attachment: List[Image] = field(default_factory=lambda: [])
|
attachment: List[Document] = field(default_factory=lambda: [])
|
||||||
sensitive: bool = False
|
sensitive: bool = False
|
||||||
type: str = "Note"
|
type: str = "Note"
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ from dataclasses import dataclass, field
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
from .base_activity import ActivityObject
|
from .base_activity import ActivityObject
|
||||||
from .image import Image
|
from .image import Document
|
||||||
|
|
||||||
|
|
||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
|
@ -28,7 +28,7 @@ class Person(ActivityObject):
|
||||||
endpoints: Dict = None
|
endpoints: Dict = None
|
||||||
name: str = None
|
name: str = None
|
||||||
summary: str = None
|
summary: str = None
|
||||||
icon: Image = field(default_factory=lambda: {})
|
icon: Document = field(default_factory=lambda: {})
|
||||||
bookwyrmUser: bool = False
|
bookwyrmUser: bool = False
|
||||||
manuallyApprovesFollowers: str = False
|
manuallyApprovesFollowers: str = False
|
||||||
discoverable: str = False
|
discoverable: str = False
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
""" undo wrapper activity """
|
""" activities that do things """
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from typing import List
|
from typing import List
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
|
@ -9,14 +9,13 @@ from .ordered_collection import CollectionItem
|
||||||
|
|
||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
class Verb(ActivityObject):
|
class Verb(ActivityObject):
|
||||||
"""generic fields for activities - maybe an unecessary level of
|
"""generic fields for activities """
|
||||||
abstraction but w/e"""
|
|
||||||
|
|
||||||
actor: str
|
actor: str
|
||||||
object: ActivityObject
|
object: ActivityObject
|
||||||
|
|
||||||
def action(self):
|
def action(self):
|
||||||
""" usually we just want to save, this can be overridden as needed """
|
""" usually we just want to update and save """
|
||||||
self.object.to_model()
|
self.object.to_model()
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,8 +23,8 @@ class Verb(ActivityObject):
|
||||||
class Create(Verb):
|
class Create(Verb):
|
||||||
""" Create activity """
|
""" Create activity """
|
||||||
|
|
||||||
to: List
|
to: List[str]
|
||||||
cc: List
|
cc: List[str] = field(default_factory=lambda: [])
|
||||||
signature: Signature = None
|
signature: Signature = None
|
||||||
type: str = "Create"
|
type: str = "Create"
|
||||||
|
|
||||||
|
@ -34,21 +33,23 @@ class Create(Verb):
|
||||||
class Delete(Verb):
|
class Delete(Verb):
|
||||||
""" Create activity """
|
""" Create activity """
|
||||||
|
|
||||||
to: List
|
to: List[str]
|
||||||
cc: List
|
cc: List[str] = field(default_factory=lambda: [])
|
||||||
type: str = "Delete"
|
type: str = "Delete"
|
||||||
|
|
||||||
def action(self):
|
def action(self):
|
||||||
""" find and delete the activity object """
|
""" find and delete the activity object """
|
||||||
obj = self.object.to_model(save=False, allow_create=False)
|
obj = self.object.to_model(save=False, allow_create=False)
|
||||||
|
if obj:
|
||||||
obj.delete()
|
obj.delete()
|
||||||
|
# if we can't find it, we don't need to delete it because we don't have it
|
||||||
|
|
||||||
|
|
||||||
@dataclass(init=False)
|
@dataclass(init=False)
|
||||||
class Update(Verb):
|
class Update(Verb):
|
||||||
""" Update activity """
|
""" Update activity """
|
||||||
|
|
||||||
to: List
|
to: List[str]
|
||||||
type: str = "Update"
|
type: str = "Update"
|
||||||
|
|
||||||
def action(self):
|
def action(self):
|
||||||
|
|
|
@ -33,4 +33,4 @@ class Image(Attachment):
|
||||||
)
|
)
|
||||||
caption = fields.TextField(null=True, blank=True, activitypub_field="name")
|
caption = fields.TextField(null=True, blank=True, activitypub_field="name")
|
||||||
|
|
||||||
activity_serializer = activitypub.Image
|
activity_serializer = activitypub.Document
|
||||||
|
|
|
@ -336,7 +336,7 @@ def image_serializer(value, alt):
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
url = "https://%s%s" % (DOMAIN, url)
|
url = "https://%s%s" % (DOMAIN, url)
|
||||||
return activitypub.Image(url=url, name=alt)
|
return activitypub.Document(url=url, name=alt)
|
||||||
|
|
||||||
|
|
||||||
class ImageField(ActivitypubFieldMixin, models.ImageField):
|
class ImageField(ActivitypubFieldMixin, models.ImageField):
|
||||||
|
|
Loading…
Reference in a new issue