diff --git a/upub/cli/src/relay.rs b/upub/cli/src/relay.rs index b8c3ac9..6ab72bf 100644 --- a/upub/cli/src/relay.rs +++ b/upub/cli/src/relay.rs @@ -1,5 +1,5 @@ use apb::{ActivityMut, BaseMut, ObjectMut}; -use sea_orm::{ActiveValue::{NotSet, Set}, DbErr, EntityTrait}; +use sea_orm::{ActiveValue::{NotSet, Set}, DbErr, EntityTrait, QueryFilter, ColumnTrait}; use upub::traits::fetch::PullError; #[derive(Debug, Clone, clap::Subcommand)] @@ -87,8 +87,9 @@ pub async fn relay(ctx: upub::Context, action: RelayCommand) -> Result<(), PullE let my_internal = upub::model::actor::Entity::ap_to_internal(ctx.base(), ctx.db()) .await? .ok_or_else(|| DbErr::RecordNotFound(ctx.base().to_string()))?; - let relation = upub::Query::related(Some(their_internal), Some(my_internal), true) - .into_model::() + let relation = upub::model::relation::Entity::find() + .filter(upub::model::relation::Column::Follower.eq(their_internal)) + .filter(upub::model::relation::Column::Following.eq(my_internal)) .one(ctx.db()) .await? .ok_or_else(|| DbErr::RecordNotFound(format!("relation-{their_internal}-{my_internal}")))?; diff --git a/upub/core/src/selector/query.rs b/upub/core/src/selector/query.rs index cdcaba1..1d8ccff 100644 --- a/upub/core/src/selector/query.rs +++ b/upub/core/src/selector/query.rs @@ -97,12 +97,8 @@ impl Query { .filter(condition) .select_only(); - for column in model::relation::Column::iter() { - select = select.select_column_as(column, format!("{}{}", model::relation::Entity.table_name(), column.to_string())); - } - for column in model::actor::Column::iter() { - select = select.select_column_as(column, format!("{}{}", model::actor::Entity.table_name(), column.to_string())); + select = select.select_column(column); } select