From 03bca17897d35a8828a443f45dd503021b61e1de Mon Sep 17 00:00:00 2001 From: alemi Date: Sat, 8 Jun 2024 02:51:17 +0200 Subject: [PATCH] fix: oops mixing activity and object of course... --- upub/core/src/selector.rs | 7 +++---- upub/routes/src/activitypub/inbox.rs | 2 +- upub/routes/src/builders.rs | 9 ++++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/upub/core/src/selector.rs b/upub/core/src/selector.rs index 96841e9..e99e633 100644 --- a/upub/core/src/selector.rs +++ b/upub/core/src/selector.rs @@ -86,7 +86,7 @@ impl FromQueryResult for RichActivity { fn from_query_result(res: &QueryResult, _pre: &str) -> Result { Ok(RichActivity { activity: model::activity::Model::from_query_result(res, model::activity::Entity.table_name())?, - object: model::object::Model::from_query_result(res, model::activity::Entity.table_name()).ok(), + object: model::object::Model::from_query_result(res, model::object::Entity.table_name()).ok(), liked: res.try_get(model::like::Entity.table_name(), &model::like::Column::Actor.to_string()).ok(), attachments: None, }) @@ -119,7 +119,7 @@ pub struct RichObject { impl FromQueryResult for RichObject { fn from_query_result(res: &QueryResult, _pre: &str) -> Result { Ok(RichObject { - object: model::object::Model::from_query_result(res, model::activity::Entity.table_name())?, + object: model::object::Model::from_query_result(res, model::object::Entity.table_name())?, liked: res.try_get(model::like::Entity.table_name(), &model::like::Column::Actor.to_string()).ok(), attachments: None, }) @@ -144,8 +144,7 @@ impl BatchFillable for Vec { async fn with_attachments(mut self, tx: &impl ConnectionTrait) -> Result { let objects : Vec = self .iter() - .filter_map(|x| x.object.as_ref()) - .map(|o| o.clone()) + .filter_map(|x| x.object.as_ref().cloned()) .collect(); let attachments = objects.load_many(model::attachment::Entity, tx).await?; diff --git a/upub/routes/src/activitypub/inbox.rs b/upub/routes/src/activitypub/inbox.rs index 9cb5974..b964691 100644 --- a/upub/routes/src/activitypub/inbox.rs +++ b/upub/routes/src/activitypub/inbox.rs @@ -1,6 +1,6 @@ use apb::{Activity, ActivityType, Base}; use axum::{extract::{Query, State}, http::StatusCode, Json}; -use sea_orm::{ActiveValue::{NotSet, Set}, ColumnTrait, Condition, EntityTrait}; +use sea_orm::{ActiveValue::{NotSet, Set}, EntityTrait}; use upub::{model::job::JobType, Context}; use crate::{AuthIdentity, Identity, builders::JsonLD}; diff --git a/upub/routes/src/builders.rs b/upub/routes/src/builders.rs index 04ef759..35e96e0 100644 --- a/upub/routes/src/builders.rs +++ b/upub/routes/src/builders.rs @@ -42,7 +42,7 @@ pub async fn paginate_activities( collection_page(&id, offset, limit, items) } -// TODO can we merge these two??? there are basically only two differences +// TODO can we merge these two??? there are basically only three differences pub async fn paginate_objects( id: String, @@ -59,7 +59,10 @@ pub async fn paginate_objects( if with_users { select = select - .join(sea_orm::JoinType::InnerJoin, upub::model::activity::Relation::Actors.def()); + .join( + sea_orm::JoinType::InnerJoin, + upub::model::object::Relation::Actors.def() // <--- difference two + ); } let items = select @@ -67,7 +70,7 @@ pub async fn paginate_objects( // TODO also limit to only local activities .limit(limit) .offset(offset) - .into_model::() // <--- difference two + .into_model::() // <--- difference three .all(db) .await? .with_attachments(db)