forked from alemi/upub
fix: also update comments count when fetching
This commit is contained in:
parent
35804730de
commit
3e0e4ff8d3
1 changed files with 6 additions and 1 deletions
|
@ -3,7 +3,7 @@ use std::collections::BTreeMap;
|
||||||
use apb::{target::Addressed, Activity, Object};
|
use apb::{target::Addressed, Activity, 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::{EntityTrait, IntoActiveModel};
|
use sea_orm::{sea_query::Expr, ColumnTrait, EntityTrait, IntoActiveModel, QueryFilter};
|
||||||
|
|
||||||
use crate::{model, VERSION};
|
use crate::{model, VERSION};
|
||||||
|
|
||||||
|
@ -155,6 +155,11 @@ async fn fetch_object_inner(ctx: &Context, id: &str, depth: usize) -> crate::Res
|
||||||
if let Some(reply) = &object_model.in_reply_to {
|
if let Some(reply) = &object_model.in_reply_to {
|
||||||
if depth <= 16 {
|
if depth <= 16 {
|
||||||
fetch_object_inner(ctx, reply, depth + 1).await?;
|
fetch_object_inner(ctx, reply, depth + 1).await?;
|
||||||
|
model::object::Entity::update_many()
|
||||||
|
.filter(model::object::Column::Id.eq(reply))
|
||||||
|
.col_expr(model::object::Column::Comments, Expr::col(model::object::Column::Comments).add(1))
|
||||||
|
.exec(ctx.db())
|
||||||
|
.await?;
|
||||||
} else {
|
} else {
|
||||||
tracing::warn!("thread deeper than 16, giving up fetching more replies");
|
tracing::warn!("thread deeper than 16, giving up fetching more replies");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue