Accepted from inbox

This commit is contained in:
asonix 2020-03-18 00:01:14 -05:00
parent 27a9030be1
commit 877fa1418e
2 changed files with 16 additions and 7 deletions

View file

@ -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"

View file

@ -27,7 +27,7 @@ use self::{
webfinger::RelayResolver,
};
pub fn response<T>(item: T) -> HttpResponse
pub fn ok<T>(item: T) -> HttpResponse
where
T: serde::ser::Serialize,
{
@ -36,6 +36,15 @@ where
.json(item)
}
pub fn accepted<T>(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<State>) -> Result<impl Responder, MyError>
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]