diff --git a/upub/routes/src/activitypub/actor/audience.rs b/upub/routes/src/activitypub/actor/audience.rs new file mode 100644 index 00000000..3aef4d8c --- /dev/null +++ b/upub/routes/src/activitypub/actor/audience.rs @@ -0,0 +1,37 @@ +use axum::extract::{Path, Query, State}; +use sea_orm::{Condition, ColumnTrait}; + +use upub::Context; + +use crate::{activitypub::Pagination, builders::JsonLD, AuthIdentity, Identity}; + +pub async fn get( + State(ctx): State, + Path(id): Path, +) -> crate::ApiResult> { + crate::builders::collection( + &upub::url!(ctx, "/actors/{id}/audience"), + None, + ) +} + +pub async fn page( + State(ctx): State, + Path(id): Path, + AuthIdentity(auth): AuthIdentity, + Query(page): Query, +) -> crate::ApiResult> { + let filter = Condition::all() + .add(auth.filter()) + .add(upub::model::object::Column::Audience.eq(ctx.uid(&id))); + + crate::builders::paginate_feed( + upub::url!(ctx, "/actors/{id}/audience/page"), + filter, + ctx.db(), + page, + auth.my_id(), + false, + ) + .await +} diff --git a/upub/routes/src/activitypub/actor/mod.rs b/upub/routes/src/activitypub/actor/mod.rs index ca66128f..6f01d8b0 100644 --- a/upub/routes/src/activitypub/actor/mod.rs +++ b/upub/routes/src/activitypub/actor/mod.rs @@ -2,6 +2,7 @@ pub mod inbox; pub mod outbox; pub mod following; pub mod notifications; +pub mod audience; use axum::extract::{Path, Query, State}; diff --git a/upub/routes/src/activitypub/mod.rs b/upub/routes/src/activitypub/mod.rs index 5d61854a..7e08cb37 100644 --- a/upub/routes/src/activitypub/mod.rs +++ b/upub/routes/src/activitypub/mod.rs @@ -55,6 +55,8 @@ impl ActivityPubRouter for Router { .route("/actors/:id/followers/page", get(ap::actor::following::page::)) .route("/actors/:id/following", get(ap::actor::following::get::)) .route("/actors/:id/following/page", get(ap::actor::following::page::)) + .route("/actors/:id/audience", get(ap::actor::audience::get)) + .route("/actors/:id/audience/page", get(ap::actor::audience::page)) // activities .route("/activities/:id", get(ap::activity::view)) // specific object routes