diff --git a/upub/routes/src/activitypub/mod.rs b/upub/routes/src/activitypub/mod.rs index 11dbc47e..f7e74d28 100644 --- a/upub/routes/src/activitypub/mod.rs +++ b/upub/routes/src/activitypub/mod.rs @@ -2,7 +2,6 @@ pub mod user; pub mod inbox; pub mod outbox; pub mod object; -pub mod context; pub mod activity; pub mod application; pub mod auth; @@ -55,13 +54,12 @@ impl ActivityPubRouter for Router { .route("/actors/:id/following/page", get(ap::user::following::page::)) // activities .route("/activities/:id", get(ap::activity::view)) - // context - .route("/context/:id", get(ap::context::get)) - .route("/context/:id/page", get(ap::context::page)) // specific object routes .route("/objects/:id", get(ap::object::view)) .route("/objects/:id/replies", get(ap::object::replies::get)) .route("/objects/:id/replies/page", get(ap::object::replies::page)) + .route("/objects/:id/context", get(ap::object::context::get)) + .route("/objects/:id/context/page", get(ap::object::context::page)) //.route("/objects/:id/likes", get(ap::object::likes::get)) //.route("/objects/:id/likes/page", get(ap::object::likes::page)) //.route("/objects/:id/shares", get(ap::object::announces::get)) diff --git a/upub/routes/src/activitypub/context.rs b/upub/routes/src/activitypub/object/context.rs similarity index 75% rename from upub/routes/src/activitypub/context.rs rename to upub/routes/src/activitypub/object/context.rs index c6ec95dc..6cceb60c 100644 --- a/upub/routes/src/activitypub/context.rs +++ b/upub/routes/src/activitypub/object/context.rs @@ -2,25 +2,22 @@ use axum::extract::{Path, Query, State}; use sea_orm::{ColumnTrait, Condition, PaginatorTrait, QueryFilter}; use upub::{model, Context}; -use crate::{AuthIdentity, builders::JsonLD}; - -use super::Pagination; +use crate::{AuthIdentity, builders::JsonLD, activitypub::Pagination}; pub async fn get( State(ctx): State, Path(id): Path, AuthIdentity(auth): AuthIdentity, ) -> crate::ApiResult> { - let local_context_id = upub::url!(ctx, "/context/{id}"); let context = ctx.oid(&id); let count = model::addressing::Entity::find_addressed(auth.my_id()) .filter(auth.filter_condition()) - .filter(model::object::Column::Context.eq(context)) + .filter(model::object::Column::Context.eq(&context)) .count(ctx.db()) .await?; - crate::builders::collection(&local_context_id, Some(count)) + crate::builders::collection(&format!("{context}/context"), Some(count)) } pub async fn page( @@ -32,7 +29,7 @@ pub async fn page( let context = ctx.oid(&id); crate::builders::paginate( - upub::url!(ctx, "/context/{id}/page"), + format!("{context}/context/page"), Condition::all() .add(auth.filter_condition()) .add(model::object::Column::Context.eq(context)), diff --git a/upub/routes/src/activitypub/object/mod.rs b/upub/routes/src/activitypub/object/mod.rs index 58cb4c83..d7d7cc8e 100644 --- a/upub/routes/src/activitypub/object/mod.rs +++ b/upub/routes/src/activitypub/object/mod.rs @@ -1,4 +1,5 @@ pub mod replies; +pub mod context; use apb::{CollectionMut, ObjectMut, LD}; use axum::extract::{Path, Query, State}; diff --git a/utils/uriproxy/lib.rs b/utils/uriproxy/lib.rs index cd807f72..7b75ffc5 100644 --- a/utils/uriproxy/lib.rs +++ b/utils/uriproxy/lib.rs @@ -5,7 +5,6 @@ pub enum UriClass { Actor, Object, Activity, - Context, } impl AsRef for UriClass { @@ -14,7 +13,6 @@ impl AsRef for UriClass { Self::Actor => "actors", Self::Object => "objects", Self::Activity => "activities", - Self::Context => "context", } } } diff --git a/web/src/components/timeline.rs b/web/src/components/timeline.rs index 5864008c..91b592a8 100644 --- a/web/src/components/timeline.rs +++ b/web/src/components/timeline.rs @@ -269,7 +269,7 @@ async fn fetch_and_update_with_user(kind: U, id: String, auth: Auth) { if let Some(actor_id) = match kind { U::Object => obj.attributed_to().id().str(), U::Activity => obj.actor().id().str(), - U::Actor | U::Context => None, + U::Actor => None, } { fetch_and_update(U::Actor, actor_id, auth).await; } diff --git a/web/src/page/object.rs b/web/src/page/object.rs index 3354fa2b..75da9658 100644 --- a/web/src/page/object.rs +++ b/web/src/page/object.rs @@ -37,7 +37,7 @@ pub fn ObjectPage(tl: Timeline) -> impl IntoView { } }; if let Ok(ctx) = obj.context().id() { - let tl_url = format!("{}/page", ctx); + let tl_url = format!("{}/context/page", Uri::api(U::Object, ctx, true)); if !tl.next.get().starts_with(&tl_url) { tl.reset(tl_url); }