From fe36ed2a52b5924b89084da28a1428cd116b294d Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 21 Mar 2024 01:42:29 +0100 Subject: [PATCH] feat: activity view embeds object --- src/activitypub/activity.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/activitypub/activity.rs b/src/activitypub/activity.rs index 267dbe20..069eec2b 100644 --- a/src/activitypub/activity.rs +++ b/src/activitypub/activity.rs @@ -1,12 +1,15 @@ use axum::{extract::{Path, State}, http::StatusCode, Json}; use sea_orm::EntityTrait; - -use crate::{activitystream::Base, model::activity, server::Context}; +use crate::{activitystream::{prelude::*, Node}, model::{activity, object}, server::Context}; pub async fn view(State(ctx) : State, Path(id): Path) -> Result, StatusCode> { - match activity::Entity::find_by_id(ctx.aid(id)).one(ctx.db()).await { - Ok(Some(activity)) => Ok(Json(activity.underlying_json_object())), + match activity::Entity::find_by_id(ctx.aid(id)) + .find_also_related(object::Entity) + .one(ctx.db()) + .await + { + Ok(Some((activity, object))) => Ok(Json(activity.underlying_json_object().set_object(Node::maybe_object(object)))), Ok(None) => Err(StatusCode::NOT_FOUND), Err(e) => { tracing::error!("error querying for activity: {e}");