1
0
Fork 0

merge in latest changes

This commit is contained in:
Hugh Rundle 2023-01-18 14:12:01 +11:00
commit d66e2fe861
353 changed files with 46899 additions and 9170 deletions

View file

@ -12,7 +12,7 @@ from bookwyrm import models
from bookwyrm.connectors import ConnectorException, get_data
from bookwyrm.signatures import make_signature
from bookwyrm.settings import DOMAIN
from bookwyrm.tasks import app
from bookwyrm.tasks import app, MEDIUM
logger = logging.getLogger(__name__)
@ -199,6 +199,11 @@ class ActivityObject:
try:
if issubclass(type(v), ActivityObject):
data[k] = v.serialize()
elif isinstance(v, list):
data[k] = [
e.serialize() if issubclass(type(e), ActivityObject) else e
for e in v
]
except TypeError:
pass
data = {k: v for (k, v) in data.items() if v is not None and k not in omit}
@ -207,7 +212,7 @@ class ActivityObject:
return data
@app.task(queue="medium_priority")
@app.task(queue=MEDIUM)
@transaction.atomic
def set_related_field(
model_name, origin_model_name, related_field_name, related_remote_id, data
@ -282,7 +287,7 @@ def resolve_remote_id(
else:
raise e
except ConnectorException:
logger.exception("Could not connect to host for remote_id: %s", remote_id)
logger.info("Could not connect to host for remote_id: %s", remote_id)
return None
# determine the model implicitly, if not provided
@ -356,7 +361,9 @@ class Link(ActivityObject):
def serialize(self, **kwargs):
"""remove fields"""
omit = ("id", "type", "@context")
omit = ("id", "@context")
if self.type == "Link":
omit += ("type",)
return super().serialize(omit=omit)
@ -364,4 +371,4 @@ class Link(ActivityObject):
class Mention(Link):
"""a subtype of Link for mentioning an actor"""
type: str = "Mention"
type: str = "Mention"

View file

@ -19,6 +19,8 @@ class BookData(ActivityObject):
viaf: str = None
wikidata: str = None
asin: str = None
aasin: str = None
isfdb: str = None
lastEditedBy: str = None
links: List[str] = field(default_factory=lambda: [])
fileLinks: List[str] = field(default_factory=lambda: [])

View file

@ -83,7 +83,7 @@ class Undo(Verb):
def action(self):
"""find and remove the activity object"""
if isinstance(self.object, str):
# it may be that sometihng should be done with these, but idk what
# it may be that something should be done with these, but idk what
# this seems just to be coming from pleroma
return
@ -94,7 +94,7 @@ class Undo(Verb):
model = apps.get_model("bookwyrm.UserFollows")
obj = self.object.to_model(model=model, save=False, allow_create=False)
if not obj:
# this could be a folloq request not a follow proper
# this could be a follow request not a follow proper
model = apps.get_model("bookwyrm.UserFollowRequest")
obj = self.object.to_model(model=model, save=False, allow_create=False)
else: