From c342b7c936b21818e88f9274f3edb3e35855db25 Mon Sep 17 00:00:00 2001 From: alemi Date: Sat, 13 Apr 2024 03:28:30 +0200 Subject: [PATCH] fix: object view quite wasteful to do it like this but for some reason previous way didn't work?? --- src/routes/activitypub/object.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/routes/activitypub/object.rs b/src/routes/activitypub/object.rs index 8399719a..1471e508 100644 --- a/src/routes/activitypub/object.rs +++ b/src/routes/activitypub/object.rs @@ -2,7 +2,7 @@ use axum::{extract::{Path, State}, http::StatusCode}; use sea_orm::{ColumnTrait, QueryFilter}; use apb::{ObjectMut, BaseMut, Node}; -use crate::{model, server::{auth::AuthIdentity, Context}}; +use crate::{model::{self, addressing::EmbeddedActivity}, server::{auth::AuthIdentity, Context}}; use super::{jsonld::LD, JsonLD}; @@ -28,14 +28,15 @@ pub async fn view( Path(id): Path, AuthIdentity(auth): AuthIdentity, ) -> Result, StatusCode> { - match model::addressing::Entity::find_objects() + match model::addressing::Entity::find_activities() .filter(model::object::Column::Id.eq(ctx.oid(id))) .filter(auth.filter_condition()) - .into_model::() + .into_model::() .one(ctx.db()) .await { - Ok(Some(object)) => Ok(JsonLD(ap_object(object).ld_context())), + Ok(Some(EmbeddedActivity { activity: _, object: Some(object) })) => Ok(JsonLD(ap_object(object).ld_context())), + Ok(Some(EmbeddedActivity { activity: _, object: None })) => Err(StatusCode::NOT_FOUND), Ok(None) => Err(StatusCode::NOT_FOUND), Err(e) => { tracing::error!("error querying for object: {e}");