feat: fetch replied posts, increase comment count

This commit is contained in:
əlemi 2024-04-19 04:03:57 +02:00
parent 39add30876
commit 13533a58d9
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -20,6 +20,15 @@ impl apb::server::Inbox for Context {
return Err(UpubError::unprocessable()); return Err(UpubError::unprocessable());
}; };
let object_model = model::object::Model::new(&object_node)?; 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 aid = activity_model.id.clone();
let oid = object_model.id.clone(); let oid = object_model.id.clone();
model::object::Entity::insert(object_model.into_active_model()).exec(self.db()).await?; model::object::Entity::insert(object_model.into_active_model()).exec(self.db()).await?;