feat(activitypub): implement user outbox endpoint and federate thoughts to followers

This commit is contained in:
2025-09-06 01:46:11 +02:00
parent e9c4088e68
commit 3dd6c0f64b
10 changed files with 411 additions and 9 deletions

View File

@@ -16,6 +16,7 @@ use models::{params::thought::CreateThoughtParams, schemas::thought::ThoughtSche
use crate::{
error::ApiError,
extractor::{AuthUser, Json, Valid},
federation,
models::{ApiErrorResponse, ParamsErrorResponse},
};
@@ -43,6 +44,13 @@ async fn thoughts_post(
.await?
.ok_or(UserError::NotFound)?; // Should not happen if auth is valid
// Spawn a background task to handle federation without blocking the response
tokio::spawn(federation::federate_thought(
state.clone(),
thought.clone(),
author.clone(),
));
let schema = ThoughtSchema::from_models(&thought, &author);
Ok((StatusCode::CREATED, Json(schema)))
}