fix: dont use builders for context
This commit is contained in:
parent
100c738336
commit
9b6b51889a
1 changed files with 26 additions and 11 deletions
|
@ -1,6 +1,6 @@
|
||||||
use axum::extract::{Path, Query, State};
|
use axum::extract::{Path, Query, State};
|
||||||
use sea_orm::{ColumnTrait, Condition, PaginatorTrait, QueryFilter};
|
use sea_orm::{ColumnTrait, Condition, PaginatorTrait, QueryFilter, QuerySelect};
|
||||||
use upub::{model, Context};
|
use upub::{model, selector::{BatchFillable, RichActivity}, Context};
|
||||||
|
|
||||||
use crate::{activitypub::Pagination, builders::JsonLD, AuthIdentity, Identity};
|
use crate::{activitypub::Pagination, builders::JsonLD, AuthIdentity, Identity};
|
||||||
|
|
||||||
|
@ -39,14 +39,29 @@ pub async fn page(
|
||||||
.add(model::object::Column::Context.eq(context))
|
.add(model::object::Column::Context.eq(context))
|
||||||
.add(filter);
|
.add(filter);
|
||||||
|
|
||||||
|
let limit = page.batch.unwrap_or(20).min(50);
|
||||||
|
let offset = page.offset.unwrap_or(0);
|
||||||
|
|
||||||
crate::builders::paginate_feed(
|
|
||||||
upub::url!(ctx, "/objects/{id}/context/page"),
|
let items = upub::Query::feed(auth.my_id(), true)
|
||||||
filter,
|
.filter(filter)
|
||||||
ctx.db(),
|
// TODO also limit to only local activities
|
||||||
page,
|
.limit(limit)
|
||||||
auth.my_id(),
|
.offset(offset)
|
||||||
false,
|
.into_model::<RichActivity>()
|
||||||
)
|
.all(ctx.db())
|
||||||
.await
|
.await?
|
||||||
|
.with_batched::<upub::model::attachment::Entity>(ctx.db())
|
||||||
|
.await?
|
||||||
|
.with_batched::<upub::model::mention::Entity>(ctx.db())
|
||||||
|
.await?
|
||||||
|
.with_batched::<upub::model::hashtag::Entity>(ctx.db())
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let items : Vec<serde_json::Value> = items
|
||||||
|
.into_iter()
|
||||||
|
.map(|item| item.ap())
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
crate::builders::collection_page(&id, offset, limit, items)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue