diff --git a/upub/routes/src/activitypub/actor/likes.rs b/upub/routes/src/activitypub/actor/likes.rs index 121db2d..d4920b2 100644 --- a/upub/routes/src/activitypub/actor/likes.rs +++ b/upub/routes/src/activitypub/actor/likes.rs @@ -1,7 +1,7 @@ use axum::extract::{Path, Query, State}; use sea_orm::{ColumnTrait, QueryFilter, QueryOrder, QuerySelect, RelationTrait}; -use upub::{model, selector::{RichObject, BatchFillable}, Context}; +use upub::{model, selector::{RichFillable, RichObject}, Context}; use crate::{activitypub::Pagination, builders::JsonLD, ApiError, AuthIdentity}; @@ -9,7 +9,7 @@ pub async fn get( State(ctx): State, Path(id): Path, ) -> crate::ApiResult> { - crate::builders::collection(upub::url!(ctx, "/actors/{id}/liked"), None) + crate::builders::collection(upub::url!(ctx, "/actors/{id}/likes"), None) } pub async fn page( @@ -25,15 +25,16 @@ pub async fn page( .await? .ok_or_else(ApiError::not_found)?; - if !auth.is(&uid) && !config.map_or(false, |x| x.show_liked_objects) { + if !auth.is(&uid) && !config.map_or(true, |x| x.show_liked_objects) { return Err(ApiError::forbidden()); } let (limit, offset) = page.pagination(); let items : Vec = upub::Query::objects(auth.my_id(), true) - .join(sea_orm::JoinType::InnerJoin, upub::model::object::Relation::Likes.def()) - .filter(auth.filter_objects()) + .join(sea_orm::JoinType::InnerJoin, upub::model::like::Relation::Objects.def()) + .join(sea_orm::JoinType::InnerJoin, upub::model::activity::Relation::Likes.def()) + .filter(auth.filter_activities()) .filter(upub::model::like::Column::Actor.eq(user.internal)) .order_by_desc(upub::model::like::Column::Published) .limit(limit) @@ -41,15 +42,11 @@ pub async fn page( .into_model::() .all(ctx.db()) .await? - .with_batched::(ctx.db()) - .await? - .with_batched::(ctx.db()) - .await? - .with_batched::(ctx.db()) + .load_batched_models(ctx.db()) .await? .into_iter() .map(|x| ctx.ap(x)) .collect(); - crate::builders::collection_page(&upub::url!(ctx, "/actors/{id}/outbox/page"), page, apb::Node::array(items)) + crate::builders::collection_page(&upub::url!(ctx, "/actors/{id}/likes/page"), page, apb::Node::array(items)) }