fix: context is now under /objects/{id}/context
just like /objects/{id}/replies, makes easier composing urls, and also more correct: context is not something we serve, but instead some reference associated to objects
This commit is contained in:
parent
b17060df3d
commit
e63433b77b
6 changed files with 9 additions and 15 deletions
|
@ -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<upub::Context> {
|
|||
.route("/actors/:id/following/page", get(ap::user::following::page::<true>))
|
||||
// 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))
|
||||
|
|
|
@ -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<Context>,
|
||||
Path(id): Path<String>,
|
||||
AuthIdentity(auth): AuthIdentity,
|
||||
) -> crate::ApiResult<JsonLD<serde_json::Value>> {
|
||||
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)),
|
|
@ -1,4 +1,5 @@
|
|||
pub mod replies;
|
||||
pub mod context;
|
||||
|
||||
use apb::{CollectionMut, ObjectMut, LD};
|
||||
use axum::extract::{Path, Query, State};
|
||||
|
|
|
@ -5,7 +5,6 @@ pub enum UriClass {
|
|||
Actor,
|
||||
Object,
|
||||
Activity,
|
||||
Context,
|
||||
}
|
||||
|
||||
impl AsRef<str> for UriClass {
|
||||
|
@ -14,7 +13,6 @@ impl AsRef<str> for UriClass {
|
|||
Self::Actor => "actors",
|
||||
Self::Object => "objects",
|
||||
Self::Activity => "activities",
|
||||
Self::Context => "context",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue