diff --git a/src/routes/activitypub/context.rs b/src/routes/activitypub/context.rs index 3ffd3783..360d21fe 100644 --- a/src/routes/activitypub/context.rs +++ b/src/routes/activitypub/context.rs @@ -36,6 +36,7 @@ pub async fn page( ctx.db(), page, auth.my_id(), + false, ) .await } diff --git a/src/routes/activitypub/inbox.rs b/src/routes/activitypub/inbox.rs index 50d38402..adb1eb38 100644 --- a/src/routes/activitypub/inbox.rs +++ b/src/routes/activitypub/inbox.rs @@ -25,6 +25,7 @@ pub async fn page( ctx.db(), page, auth.my_id(), + false, ) .await } diff --git a/src/routes/activitypub/object/replies.rs b/src/routes/activitypub/object/replies.rs index a01ba477..b9514952 100644 --- a/src/routes/activitypub/object/replies.rs +++ b/src/routes/activitypub/object/replies.rs @@ -42,6 +42,7 @@ pub async fn page( ctx.db(), page, auth.my_id(), + false, ) .await } diff --git a/src/routes/activitypub/outbox.rs b/src/routes/activitypub/outbox.rs index 1cd7e639..3abd0b33 100644 --- a/src/routes/activitypub/outbox.rs +++ b/src/routes/activitypub/outbox.rs @@ -1,4 +1,5 @@ use axum::{extract::{Query, State}, http::StatusCode, Json}; +use sea_orm::{ColumnTrait, Condition}; use crate::{errors::UpubError, routes::activitypub::{CreationResult, JsonLD, Pagination}, server::{auth::AuthIdentity, Context}, url}; @@ -13,10 +14,13 @@ pub async fn page( ) -> crate::Result> { crate::server::builders::paginate( url!(ctx, "/outbox/page"), - auth.filter_condition(), // TODO filter local only stuff + Condition::all() + .add(auth.filter_condition()) + .add(crate::model::actor::Column::Domain.eq(ctx.domain().to_string())), ctx.db(), page, auth.my_id(), + true, ) .await } diff --git a/src/routes/activitypub/user/inbox.rs b/src/routes/activitypub/user/inbox.rs index 7ccdc5cb..0049e8af 100644 --- a/src/routes/activitypub/user/inbox.rs +++ b/src/routes/activitypub/user/inbox.rs @@ -42,6 +42,7 @@ pub async fn page( ctx.db(), page, auth.my_id(), + false, ) .await } diff --git a/src/routes/activitypub/user/outbox.rs b/src/routes/activitypub/user/outbox.rs index 774eb75c..b88b1c91 100644 --- a/src/routes/activitypub/user/outbox.rs +++ b/src/routes/activitypub/user/outbox.rs @@ -30,6 +30,7 @@ pub async fn page( ctx.db(), page, auth.my_id(), + false, ) .await } diff --git a/src/server/builders.rs b/src/server/builders.rs index 6ca040c0..0f8b6413 100644 --- a/src/server/builders.rs +++ b/src/server/builders.rs @@ -1,5 +1,5 @@ use apb::{BaseMut, CollectionMut, CollectionPageMut}; -use sea_orm::{Condition, DatabaseConnection, QueryFilter, QuerySelect}; +use sea_orm::{Condition, DatabaseConnection, QueryFilter, QuerySelect, RelationTrait}; use crate::{model::{addressing::Event, attachment::BatchFillable}, routes::activitypub::{jsonld::LD, JsonLD, Pagination}}; @@ -9,11 +9,19 @@ pub async fn paginate( db: &DatabaseConnection, page: Pagination, my_id: Option, + with_users: bool, // TODO ewww too many arguments for this weird function... ) -> crate::Result> { let limit = page.batch.unwrap_or(20).min(50); let offset = page.offset.unwrap_or(0); - let items = crate::model::addressing::Entity::find_addressed(my_id) + let mut select = crate::model::addressing::Entity::find_addressed(my_id); + + if with_users { + select = select + .join(sea_orm::JoinType::InnerJoin, crate::model::activity::Relation::Actors.def()); + } + + let items = select .filter(filter) // TODO also limit to only local activities .limit(limit)