diff --git a/src/inbox.rs b/src/inbox.rs index 60ee48e..55f0402 100644 --- a/src/inbox.rs +++ b/src/inbox.rs @@ -1,9 +1,9 @@ use crate::{ + accepted, apub::{AcceptedActors, AcceptedObjects, ValidTypes}, db_actor::Db, error::MyError, requests::Requests, - response, state::{State, UrlKind}, }; use activitystreams::{ @@ -102,7 +102,7 @@ async fn handle_undo( let _ = client2.deliver(inbox, &undo2).await; }); - Ok(response(undo)) + Ok(accepted(undo)) } async fn handle_forward( @@ -116,7 +116,7 @@ async fn handle_forward( let inboxes = get_inboxes(state, &actor, &object_id).await?; client.deliver_many(inboxes, input.clone()); - Ok(response(input)) + Ok(accepted(input)) } async fn handle_relay( @@ -139,7 +139,7 @@ async fn handle_relay( state.cache(object_id.to_owned(), activity_id).await; - Ok(response(announce)) + Ok(accepted(announce)) } async fn handle_follow( @@ -180,7 +180,7 @@ async fn handle_follow( let _ = client2.deliver(inbox, &accept2).await; }); - Ok(response(accept)) + Ok(accepted(accept)) } // Generate a type that says "I want to stop following you" diff --git a/src/main.rs b/src/main.rs index b508e85..6b5e7d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,7 +27,7 @@ use self::{ webfinger::RelayResolver, }; -pub fn response(item: T) -> HttpResponse +pub fn ok(item: T) -> HttpResponse where T: serde::ser::Serialize, { @@ -36,6 +36,15 @@ where .json(item) } +pub fn accepted(item: T) -> HttpResponse +where + T: serde::ser::Serialize, +{ + HttpResponse::Accepted() + .content_type("application/activity+json") + .json(item) +} + async fn index() -> impl Responder { "hewwo, mr obama" } @@ -69,7 +78,7 @@ async fn actor_route(state: web::Data) -> Result public_key_pem: state.settings.public_key.to_pem_pkcs8()?, }; - Ok(response(public_key.extend(application))) + Ok(ok(public_key.extend(application))) } #[actix_rt::main]