From e6b40f023943c56e2644a29e12554584c97e7145 Mon Sep 17 00:00:00 2001 From: alemi Date: Tue, 25 Jun 2024 05:14:59 +0200 Subject: [PATCH] fix: oops doesnt work that way :( --- upub/cli/src/relay.rs | 7 ++++--- upub/core/src/selector/query.rs | 6 +----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/upub/cli/src/relay.rs b/upub/cli/src/relay.rs index b8c3ac9a..6ab72bfa 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 cdcaba17..1d8ccff1 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