diff --git a/src/server/inbox.rs b/src/server/inbox.rs index 9c5a9580..1689323f 100644 --- a/src/server/inbox.rs +++ b/src/server/inbox.rs @@ -18,6 +18,11 @@ impl apb::server::Inbox for Context { tracing::error!("refusing to process activity without embedded object: {}", serde_json::to_string_pretty(&activity).unwrap()); return Err(UpubError::unprocessable()); }; + if let Some(reply) = object_node.in_reply_to().id() { + if let Err(e) = self.fetch_object(&reply).await { + tracing::warn!("failed fetching replies for received object: {e}"); + } + } let activity_model = self.insert_activity(activity, Some(server.clone())).await?; let object_model = self.insert_object(object_node, Some(server)).await?; let expanded_addressing = self.expand_addressing(activity_model.addressed()).await?; diff --git a/src/server/normalizer.rs b/src/server/normalizer.rs index d7253a9e..8aeef667 100644 --- a/src/server/normalizer.rs +++ b/src/server/normalizer.rs @@ -53,13 +53,11 @@ impl Normalizer for super::Context { // update replies counter if let Set(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::Replies, Expr::col(model::object::Column::Replies).add(1)) - .exec(self.db()) - .await?; - } + model::object::Entity::update_many() + .filter(model::object::Column::Id.eq(in_reply_to)) + .col_expr(model::object::Column::Replies, Expr::col(model::object::Column::Replies).add(1)) + .exec(self.db()) + .await?; } // update statuses counter if let Some(object_author) = uid { diff --git a/src/server/outbox.rs b/src/server/outbox.rs index eae93b01..e36993a4 100644 --- a/src/server/outbox.rs +++ b/src/server/outbox.rs @@ -36,6 +36,9 @@ impl apb::server::Outbox for Context { let aid = self.aid(&uuid::Uuid::new_v4().to_string()); let activity_targets = activity.addressed(); + if let Some(reply) = object.in_reply_to().id() { + self.fetch_object(&reply).await?; + } // TODO regex hell here i come... let re = regex::Regex::new(r"@(.+)@([^ ]+)").expect("failed compiling regex pattern");