From 9ef03664f2255ebd270ffd44bc597121b86725fc Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 31 Oct 2020 12:59:15 -0700 Subject: [PATCH] lookup books when resolving activity json --- bookwyrm/activitypub/base_activity.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bookwyrm/activitypub/base_activity.py b/bookwyrm/activitypub/base_activity.py index fc5b11288..79987b50a 100644 --- a/bookwyrm/activitypub/base_activity.py +++ b/bookwyrm/activitypub/base_activity.py @@ -2,6 +2,8 @@ from dataclasses import dataclass, fields, MISSING from json import JSONEncoder +from bookwyrm import books_manager, models + from django.db.models.fields.related_descriptors \ import ForwardManyToOneDescriptor @@ -102,6 +104,9 @@ class ActivityObject: def resolve_foreign_key(model, remote_id): ''' look up the remote_id on an activity json field ''' + if model in [models.Edition, models.Work]: + return books_manager.get_or_create_book(remote_id) + result = model.objects if hasattr(model.objects, 'select_subclasses'): result = result.select_subclasses()