use tag to store neodb item in AP message
This commit is contained in:
parent
278e6f0d61
commit
67b1e5100e
7 changed files with 23 additions and 14 deletions
|
@ -361,7 +361,7 @@ class Item(SoftDeleteMixin, PolymorphicModel):
|
|||
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():
|
||||
|
|
|
@ -25,7 +25,7 @@ class Comment(Content):
|
|||
"updated": self.edited_time.isoformat(),
|
||||
"attributedTo": self.owner.actor_uri,
|
||||
"relatedWith": self.item.absolute_url,
|
||||
"url": self.absolute_url,
|
||||
"href": self.absolute_url,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -34,7 +34,7 @@ class Rating(Content):
|
|||
"updated": self.edited_time.isoformat(),
|
||||
"attributedTo": self.owner.actor_uri,
|
||||
"relatedWith": self.item.absolute_url,
|
||||
"url": self.absolute_url,
|
||||
"href": self.absolute_url,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -73,7 +73,7 @@ class ShelfMember(ListMember):
|
|||
"updated": self.edited_time.isoformat(),
|
||||
"attributedTo": self.owner.actor_uri,
|
||||
"relatedWith": self.item.absolute_url,
|
||||
"url": self.absolute_url,
|
||||
"href": self.absolute_url,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit ba099b8e02a8ed795fb0e70a51db478c368e3133
|
||||
Subproject commit aecd500619beff9c848ff041fff6cfa54fe8211b
|
|
@ -30,18 +30,25 @@ _supported_ap_journal_types = {
|
|||
}
|
||||
|
||||
|
||||
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")
|
||||
|
|
|
@ -420,7 +420,8 @@ class Takahe:
|
|||
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:
|
||||
|
|
Loading…
Add table
Reference in a new issue