From 13533a58d9a26edefc38592826ae38127d45b490 Mon Sep 17 00:00:00 2001 From: alemi Date: Fri, 19 Apr 2024 04:03:57 +0200 Subject: [PATCH] feat: fetch replied posts, increase comment count --- src/server/inbox.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/server/inbox.rs b/src/server/inbox.rs index 5f2239b9..cecd0021 100644 --- a/src/server/inbox.rs +++ b/src/server/inbox.rs @@ -20,6 +20,15 @@ impl apb::server::Inbox for Context { return Err(UpubError::unprocessable()); }; let object_model = model::object::Model::new(&object_node)?; + if let Some(ref in_reply_to) = object_model.in_reply_to { + if self.fetch_object(in_reply_to).await.is_ok() { + model::object::Entity::update_many() + .filter(model::object::Column::Id.eq(in_reply_to)) + .col_expr(model::object::Column::Comments, Expr::col(model::object::Column::Comments).add(1)) + .exec(self.db()) + .await?; + } + } let aid = activity_model.id.clone(); let oid = object_model.id.clone(); model::object::Entity::insert(object_model.into_active_model()).exec(self.db()).await?;