1
0
Fork 0
forked from alemi/upub

fix: fetch object on inbox/outbox, not normalizer

should also fix the fact that some posts miss context
This commit is contained in:
əlemi 2024-05-30 19:51:06 +02:00
parent 9c4467f2da
commit a3921622cb
Signed by: alemi
GPG key ID: A4895B84D311642C
3 changed files with 13 additions and 7 deletions

View file

@ -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()); tracing::error!("refusing to process activity without embedded object: {}", serde_json::to_string_pretty(&activity).unwrap());
return Err(UpubError::unprocessable()); 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 activity_model = self.insert_activity(activity, Some(server.clone())).await?;
let object_model = self.insert_object(object_node, Some(server)).await?; let object_model = self.insert_object(object_node, Some(server)).await?;
let expanded_addressing = self.expand_addressing(activity_model.addressed()).await?; let expanded_addressing = self.expand_addressing(activity_model.addressed()).await?;

View file

@ -53,13 +53,11 @@ impl Normalizer for super::Context {
// update replies counter // update replies counter
if let Set(Some(ref in_reply_to)) = object_model.in_reply_to { 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()
model::object::Entity::update_many() .filter(model::object::Column::Id.eq(in_reply_to))
.filter(model::object::Column::Id.eq(in_reply_to)) .col_expr(model::object::Column::Replies, Expr::col(model::object::Column::Replies).add(1))
.col_expr(model::object::Column::Replies, Expr::col(model::object::Column::Replies).add(1)) .exec(self.db())
.exec(self.db()) .await?;
.await?;
}
} }
// update statuses counter // update statuses counter
if let Some(object_author) = uid { if let Some(object_author) = uid {

View file

@ -36,6 +36,9 @@ impl apb::server::Outbox for Context {
let aid = self.aid(&uuid::Uuid::new_v4().to_string()); let aid = self.aid(&uuid::Uuid::new_v4().to_string());
let activity_targets = activity.addressed(); 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... // TODO regex hell here i come...
let re = regex::Regex::new(r"@(.+)@([^ ]+)").expect("failed compiling regex pattern"); let re = regex::Regex::new(r"@(.+)@([^ ]+)").expect("failed compiling regex pattern");