From 1e8cd3290593193c5e2ce1bc0c7e00e328573f7a Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 14 Aug 2024 15:41:10 +0200 Subject: [PATCH] fix: Query::objects is not ordered by default so its possible to select only ids --- upub/core/src/selector/query.rs | 1 - upub/routes/src/activitypub/object/context.rs | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/upub/core/src/selector/query.rs b/upub/core/src/selector/query.rs index 7cfab01..6cf7f1a 100644 --- a/upub/core/src/selector/query.rs +++ b/upub/core/src/selector/query.rs @@ -52,7 +52,6 @@ impl Query { let mut select = model::addressing::Entity::find() .distinct() .join(sea_orm::JoinType::InnerJoin, model::addressing::Relation::Objects.def()) - .order_by(model::object::Column::Published, Order::Desc) .select_only(); for col in model::object::Column::iter() { diff --git a/upub/routes/src/activitypub/object/context.rs b/upub/routes/src/activitypub/object/context.rs index 618b136..4b4621f 100644 --- a/upub/routes/src/activitypub/object/context.rs +++ b/upub/routes/src/activitypub/object/context.rs @@ -1,5 +1,5 @@ use axum::extract::{Path, Query, State}; -use sea_orm::{ColumnTrait, Condition, PaginatorTrait, QueryFilter, QuerySelect}; +use sea_orm::{ColumnTrait, Condition, Order, PaginatorTrait, QueryFilter, QueryOrder, QuerySelect}; use upub::{model, selector::{BatchFillable, RichActivity}, Context}; use crate::{activitypub::Pagination, builders::JsonLD, AuthIdentity, Identity}; @@ -45,7 +45,7 @@ pub async fn page( let items = upub::Query::objects(auth.my_id()) .filter(filter) - // TODO also limit to only local activities + .order_by(model::object::Column::Published, Order::Desc) .limit(limit) .offset(offset) .into_model::()