component AP gateway: get items when not found in cache in apGetLocalObject:
rel 370
This commit is contained in:
parent
9f6d69c75d
commit
9a5801fedd
1 changed files with 23 additions and 8 deletions
|
|
@ -389,16 +389,31 @@ class APGateway:
|
|||
self.client, author_jid, node
|
||||
)
|
||||
if not cached_node:
|
||||
raise exceptions.NotFound
|
||||
cached_items, __ = await self.host.memory.storage.getItems(
|
||||
cached_node, item_ids=[item_id]
|
||||
)
|
||||
if not cached_items:
|
||||
raise exceptions.NotFound(
|
||||
f"item {item_id!r} is not found in cache"
|
||||
log.debug(f"node {node!r} at {author_jid} is not found in cache")
|
||||
found_item = None
|
||||
else:
|
||||
cached_items, __ = await self.host.memory.storage.getItems(
|
||||
cached_node, item_ids=[item_id]
|
||||
)
|
||||
if not cached_items:
|
||||
log.debug(
|
||||
f"item {item_id!r} of {node!r} at {author_jid} is not found in "
|
||||
"cache"
|
||||
)
|
||||
found_item = None
|
||||
else:
|
||||
found_item = cached_items[0].data
|
||||
|
||||
if found_item is None:
|
||||
# the node is not in cache, we have to make a request to retrieve the item
|
||||
# if doesn't exist, getItems will raise a NotFound exception
|
||||
found_items, __ = await self._p.getItems(
|
||||
self.client, author_jid, node, item_ids=[item_id]
|
||||
)
|
||||
found_item = found_items[0]
|
||||
|
||||
mb_data = await self._m.item2mbdata(
|
||||
self.client, cached_items[0].data, author_jid, node
|
||||
self.client, found_item, author_jid, node
|
||||
)
|
||||
ap_item = await self.mbdata2APitem(self.client, mb_data)
|
||||
# the URL must return the object and not the activity
|
||||
|
|
|
|||
Loading…
Reference in a new issue