#15 @context security vocab: actor JSON now uses actor_ap_context() which includes W3C security vocab + Mastodon toot extensions (manuallyApprovesFollowers, discoverable, featured). Applied to actor_handler, actor_json(), broadcast_actor_update(). Activity JSON keeps plain AS context (no security vocab needed). #17 HTTP Digest (documented, no code change): production mode (debug=false) REQUIRES Digest header on inbound POSTs via require_digest() in the non-compat normalization config. Added doc comment to ApFederationConfig::new() to clarify. #26 Integration tests: 3 new tokio tests in src/tests/integration.rs using in-memory trait stubs. Tests cover: - check_guards idempotency (duplicate activity rejected) - check_guards domain block (blocked domain skipped) - extract_and_dispatch_mentions (on_mention called for local actor)
25 lines
886 B
Rust
25 lines
886 B
Rust
use activitypub_federation::{
|
|
axum::json::FederationJson, config::Data, protocol::context::WithContext, traits::Object,
|
|
};
|
|
use axum::extract::Path;
|
|
|
|
use crate::actors::{Person, get_local_actor};
|
|
use crate::data::FederationData;
|
|
use crate::error::Error;
|
|
use crate::urls::actor_ap_context;
|
|
|
|
/// Serves the AP actor JSON for a local user.
|
|
/// The path parameter is the user's UUID (matching the canonical actor URL).
|
|
pub async fn actor_handler(
|
|
Path(user_id_str): Path<String>,
|
|
data: Data<FederationData>,
|
|
) -> Result<FederationJson<WithContext<Person>>, Error> {
|
|
let user_id = uuid::Uuid::parse_str(&user_id_str)
|
|
.map_err(|_| Error::not_found(anyhow::anyhow!("user not found")))?;
|
|
|
|
let db_actor = get_local_actor(user_id, &data).await?;
|
|
let person = db_actor.into_json(&data).await?;
|
|
|
|
Ok(FederationJson(WithContext::new(person, actor_ap_context())))
|
|
}
|