fix: fetch actor/object handles "pretty url"

it does an extra fetch which is wasteful but it would fetch and then
fail anyway before so i think this is an improvement
This commit is contained in:
əlemi 2024-07-15 01:54:13 +02:00
parent 3d6c144c55
commit a7004d1603
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -328,6 +328,12 @@ impl Fetcher for crate::Context {
let document = self.pull(id).await?.actor()?;
if document.id()? != id {
if let Some(x) = crate::model::actor::Entity::find_by_ap_id(document.id()?).one(tx).await? {
return Ok(x); // already in db but we had to follow the "pretty" url, mehh
}
}
self.resolve_user(document, tx).await
}
@ -384,6 +390,12 @@ async fn fetch_object_r(ctx: &crate::Context, id: &str, depth: u32, tx: &impl Co
let object = ctx.pull(id).await?.object()?;
if object.id()? != id {
if let Some(x) = crate::model::object::Entity::find_by_ap_id(object.id()?).one(tx).await? {
return Ok(x); // already in db but we had to follow the "pretty" url, mehh
}
}
resolve_object_r(ctx, object, depth, tx).await
}