diff --git a/src/model/addressing.rs b/src/model/addressing.rs index ad928c6a..3837b097 100644 --- a/src/model/addressing.rs +++ b/src/model/addressing.rs @@ -1,5 +1,5 @@ use apb::{ActivityMut, ObjectMut}; -use sea_orm::{entity::prelude::*, FromQueryResult, Iterable, QuerySelect, SelectColumns}; +use sea_orm::{entity::prelude::*, FromQueryResult, Iterable, Order, QueryOrder, QuerySelect, SelectColumns}; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "addressing")] @@ -137,7 +137,8 @@ impl Entity { .distinct() .select_only() .join(sea_orm::JoinType::InnerJoin, Relation::Activity.def()) - .join(sea_orm::JoinType::LeftJoin, crate::model::activity::Relation::Object.def()); + .join(sea_orm::JoinType::LeftJoin, crate::model::activity::Relation::Object.def()) + .order_by(crate::model::activity::Column::Published, Order::Desc); for col in crate::model::activity::Column::iter() { select = select.select_column_as(col, format!("{}{}", crate::model::activity::Entity.table_name(), col.to_string())); @@ -155,7 +156,8 @@ impl Entity { .distinct() .select_only() .join(sea_orm::JoinType::InnerJoin, Relation::Object.def()) - .join(sea_orm::JoinType::LeftJoin, crate::model::object::Relation::Activity.def()); + .join(sea_orm::JoinType::LeftJoin, crate::model::object::Relation::Activity.def()) + .order_by(crate::model::object::Column::Published, Order::Desc); for col in crate::model::object::Column::iter() { select = select.select_column_as(col, format!("{}{}", crate::model::object::Entity.table_name(), col.to_string())); diff --git a/src/routes/activitypub/context.rs b/src/routes/activitypub/context.rs index 37098055..868975d1 100644 --- a/src/routes/activitypub/context.rs +++ b/src/routes/activitypub/context.rs @@ -43,7 +43,6 @@ pub async fn page( let items = model::addressing::Entity::find_objects() .filter(auth.filter_condition()) .filter(model::object::Column::Context.eq(context)) - .order_by(model::addressing::Column::Published, Order::Desc) .limit(limit) .offset(offset) .into_model::() diff --git a/src/routes/activitypub/inbox.rs b/src/routes/activitypub/inbox.rs index 152a3b1d..ba402e1a 100644 --- a/src/routes/activitypub/inbox.rs +++ b/src/routes/activitypub/inbox.rs @@ -22,7 +22,6 @@ pub async fn page( let offset = page.offset.unwrap_or(0); let activities = model::addressing::Entity::find_activities() .filter(auth.filter_condition()) - .order_by(model::addressing::Column::Published, Order::Desc) .limit(limit) .offset(offset) .into_model::() diff --git a/src/routes/activitypub/object/replies.rs b/src/routes/activitypub/object/replies.rs index 04d45621..6dd25910 100644 --- a/src/routes/activitypub/object/replies.rs +++ b/src/routes/activitypub/object/replies.rs @@ -42,7 +42,6 @@ pub async fn page( .filter(auth.filter_condition()) .filter(model::object::Column::InReplyTo.eq(oid)) // TODO also limit to only local activities - .order_by(model::addressing::Column::Published, Order::Desc) .limit(limit) .offset(offset) .into_model::() diff --git a/src/routes/activitypub/outbox.rs b/src/routes/activitypub/outbox.rs index 9393e6d8..189513f3 100644 --- a/src/routes/activitypub/outbox.rs +++ b/src/routes/activitypub/outbox.rs @@ -18,7 +18,6 @@ pub async fn page( let items = model::addressing::Entity::find_activities() .filter(auth.filter_condition()) // TODO also limit to only local activities - .order_by(model::addressing::Column::Published, Order::Desc) .limit(limit) .offset(offset) .into_model::() diff --git a/src/routes/activitypub/user/inbox.rs b/src/routes/activitypub/user/inbox.rs index 6729ddd8..0591c538 100644 --- a/src/routes/activitypub/user/inbox.rs +++ b/src/routes/activitypub/user/inbox.rs @@ -36,7 +36,6 @@ pub async fn page( let offset = page.offset.unwrap_or(0); let activities = model::addressing::Entity::find_activities() .filter(model::addressing::Column::Actor.eq(&uid)) - .order_by(model::addressing::Column::Published, Order::Desc) .offset(offset) .limit(limit) .into_model::() diff --git a/src/routes/activitypub/user/outbox.rs b/src/routes/activitypub/user/outbox.rs index 5c311d5a..d51d42e8 100644 --- a/src/routes/activitypub/user/outbox.rs +++ b/src/routes/activitypub/user/outbox.rs @@ -30,7 +30,6 @@ pub async fn page( let activities = model::addressing::Entity::find_activities() .filter(model::activity::Column::Actor.eq(&uid)) .filter(auth.filter_condition()) - .order_by(model::addressing::Column::Published, Order::Desc) .limit(limit) .offset(offset) .into_model::() diff --git a/src/routes/mastodon/accounts.rs b/src/routes/mastodon/accounts.rs index d8935570..b8f106f4 100644 --- a/src/routes/mastodon/accounts.rs +++ b/src/routes/mastodon/accounts.rs @@ -72,8 +72,7 @@ pub async fn statuses( let uid = ctx.uid(id); model::addressing::Entity::find_activities() .filter(model::activity::Column::Actor.eq(uid)) - .filter(auth.filter_condition()) - .order_by(model::addressing::Column::Published, Order::Desc); + .filter(auth.filter_condition()); todo!() }