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()