diff --git a/catalog/common/models.py b/catalog/common/models.py index 949909e8..ce3dd512 100644 --- a/catalog/common/models.py +++ b/catalog/common/models.py @@ -361,7 +361,7 @@ def ap_object_type(self): def ap_object_ref(self): o = { "type": self.get_ap_object_type(), - "url": self.absolute_url, + "href": self.absolute_url, "name": self.title, } if self.has_cover(): diff --git a/journal/models/comment.py b/journal/models/comment.py index 2af04e22..78189ff5 100644 --- a/journal/models/comment.py +++ b/journal/models/comment.py @@ -25,7 +25,7 @@ def ap_object(self): "updated": self.edited_time.isoformat(), "attributedTo": self.owner.actor_uri, "relatedWith": self.item.absolute_url, - "url": self.absolute_url, + "href": self.absolute_url, } @classmethod diff --git a/journal/models/rating.py b/journal/models/rating.py index 80479c93..bd7505ec 100644 --- a/journal/models/rating.py +++ b/journal/models/rating.py @@ -34,7 +34,7 @@ def ap_object(self): "updated": self.edited_time.isoformat(), "attributedTo": self.owner.actor_uri, "relatedWith": self.item.absolute_url, - "url": self.absolute_url, + "href": self.absolute_url, } @classmethod diff --git a/journal/models/shelf.py b/journal/models/shelf.py index 8f9352ab..0560325f 100644 --- a/journal/models/shelf.py +++ b/journal/models/shelf.py @@ -73,7 +73,7 @@ def ap_object(self): "updated": self.edited_time.isoformat(), "attributedTo": self.owner.actor_uri, "relatedWith": self.item.absolute_url, - "url": self.absolute_url, + "href": self.absolute_url, } @classmethod diff --git a/neodb-takahe b/neodb-takahe index ba099b8e..aecd5006 160000 --- a/neodb-takahe +++ b/neodb-takahe @@ -1 +1 @@ -Subproject commit ba099b8e02a8ed795fb0e70a51db478c368e3133 +Subproject commit aecd500619beff9c848ff041fff6cfa54fe8211b diff --git a/takahe/ap_handlers.py b/takahe/ap_handlers.py index 3c9ce8cd..45e5c659 100644 --- a/takahe/ap_handlers.py +++ b/takahe/ap_handlers.py @@ -30,18 +30,25 @@ } -def _parse_links(objects): - logger.debug(f"Parsing links from {objects}") - items = [] +def _parse_item_links(objects): + logger.debug(f"Parsing item links from {objects}") + items = [ + obj["href"] + for obj in objects + if obj["type"] in _supported_ap_catalog_item_types + ] + return items + + +def _parse_piece_objects(objects): + logger.debug(f"Parsing pieces from {objects}") pieces = [] for obj in objects: - if obj["type"] in _supported_ap_catalog_item_types: - items.append(obj["url"]) - elif obj["type"] in _supported_ap_journal_types.keys(): + if obj["type"] in _supported_ap_journal_types.keys(): pieces.append(obj) else: logger.warning(f'Unknown link type {obj["type"]}') - return items, pieces + return pieces def _get_or_create_item_by_ap_url(url): @@ -70,7 +77,8 @@ def _update_or_create_post(pk, obj): if not post.type_data: logger.warning(f"Post {post} has no type_data") return - items, pieces = _parse_links(post.type_data["object"]["relatedWith"]) + items = _parse_item_links(post.type_data["object"]["tag"]) + pieces = _parse_piece_objects(post.type_data["object"]["relatedWith"]) logger.info(f"Post {post} has items {items} and pieces {pieces}") if len(items) == 0: logger.warning(f"Post {post} has no remote items") diff --git a/takahe/utils.py b/takahe/utils.py index 3c3975ca..29ff4dd1 100644 --- a/takahe/utils.py +++ b/takahe/utils.py @@ -420,7 +420,8 @@ def post_mark(mark, share_as_new_post: bool) -> Post | None: content = f"{stars}\n{mark.comment_text or ''}{tags}" data = { "object": { - "relatedWith": [mark.item.ap_object_ref, mark.shelfmember.ap_object] + "tag": [mark.item.ap_object_ref], + "relatedWith": [mark.shelfmember.ap_object], } } if mark.comment: