diff --git a/src/actix_web/response.rs b/src/actix_web/response.rs index bc63d52..bfb7377 100644 --- a/src/actix_web/response.rs +++ b/src/actix_web/response.rs @@ -10,7 +10,9 @@ use serde::Serialize; use serde_json::Value; use url::Url; -/// TODO +/// Generates HTTP response to serve the object for fetching from other instances. +/// +/// `federation_context` is the value of `@context`. pub fn create_http_response( data: T, federation_context: &Value, diff --git a/src/protocol/tombstone.rs b/src/protocol/tombstone.rs index 16fbc35..950eac9 100644 --- a/src/protocol/tombstone.rs +++ b/src/protocol/tombstone.rs @@ -4,7 +4,7 @@ use crate::kinds::object::TombstoneType; use serde::{Deserialize, Serialize}; use url::Url; -/// For serving deleted objects +/// Represents a local object that was deleted #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Tombstone { diff --git a/src/traits/mod.rs b/src/traits/mod.rs index b255b48..7651573 100644 --- a/src/traits/mod.rs +++ b/src/traits/mod.rs @@ -171,10 +171,13 @@ pub trait Object: Sized + Debug { /// create and update, so an `upsert` operation should be used. async fn from_json(json: Self::Kind, data: &Data) -> Result; - /// Convert the data to json and turn it into an HTTP Response with the correct ActivityPub - /// headers. + /// Generates HTTP response to serve the object for fetching from other instances. /// - /// actix-web doesn't allow pretty-print for json so we need to do this manually. + /// - If the object has a remote domain, sends a redirect to the original instance. + /// - If [Object.is_deleted] returns true, returns a [crate::protocol::tombstone::Tombstone] instead. + /// - Otherwise serves the object JSON using [Object.into_json] and pretty-print + /// + /// `federation_context` is the value of `@context`. #[cfg(feature = "actix-web")] async fn http_response( self,