forked from alemi/upub
fix: after fetching object recheck if present
This commit is contained in:
parent
6edb379578
commit
6efc5c4ad6
1 changed files with 9 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use apb::{target::Addressed, Activity, Collection, CollectionPage, Link, Object};
|
use apb::{target::Addressed, Activity, Base, Collection, CollectionPage, Link, Object};
|
||||||
use base64::Engine;
|
use base64::Engine;
|
||||||
use reqwest::{header::{ACCEPT, CONTENT_TYPE, USER_AGENT}, Method, Response};
|
use reqwest::{header::{ACCEPT, CONTENT_TYPE, USER_AGENT}, Method, Response};
|
||||||
use sea_orm::{sea_query::Expr, ColumnTrait, EntityTrait, IntoActiveModel, QueryFilter};
|
use sea_orm::{sea_query::Expr, ColumnTrait, EntityTrait, IntoActiveModel, QueryFilter};
|
||||||
|
@ -288,6 +288,14 @@ async fn fetch_object_inner(ctx: &Context, id: &str, depth: usize) -> crate::Res
|
||||||
Method::GET, id, None, &format!("https://{}", ctx.domain()), &ctx.app().private_key, ctx.domain(),
|
Method::GET, id, None, &format!("https://{}", ctx.domain()), &ctx.app().private_key, ctx.domain(),
|
||||||
).await?.json::<serde_json::Value>().await?;
|
).await?.json::<serde_json::Value>().await?;
|
||||||
|
|
||||||
|
if let Some(oid) = object.id() {
|
||||||
|
if oid != id {
|
||||||
|
if let Some(x) = model::object::Entity::find_by_id(oid).one(ctx.db()).await? {
|
||||||
|
return Ok(x); // already in db, but with id different that given url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(attributed_to) = object.attributed_to().id() {
|
if let Some(attributed_to) = object.attributed_to().id() {
|
||||||
if let Err(e) = ctx.fetch_user(&attributed_to).await {
|
if let Err(e) = ctx.fetch_user(&attributed_to).await {
|
||||||
tracing::warn!("could not get actor of fetched object: {e}");
|
tracing::warn!("could not get actor of fetched object: {e}");
|
||||||
|
|
Loading…
Reference in a new issue