fix: fetch object on inbox/outbox, not normalizer
should also fix the fact that some posts miss context
This commit is contained in:
parent
9c4467f2da
commit
a3921622cb
3 changed files with 13 additions and 7 deletions
|
@ -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?;
|
||||
|
|
|
@ -53,14 +53,12 @@ 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?;
|
||||
}
|
||||
}
|
||||
// update statuses counter
|
||||
if let Some(object_author) = uid {
|
||||
model::actor::Entity::update_many()
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue