mirror of
https://git.asonix.dog/asonix/relay.git
synced 2024-12-29 22:00:31 +00:00
Accepted from inbox
This commit is contained in:
parent
27a9030be1
commit
877fa1418e
2 changed files with 16 additions and 7 deletions
10
src/inbox.rs
10
src/inbox.rs
|
@ -1,9 +1,9 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
|
accepted,
|
||||||
apub::{AcceptedActors, AcceptedObjects, ValidTypes},
|
apub::{AcceptedActors, AcceptedObjects, ValidTypes},
|
||||||
db_actor::Db,
|
db_actor::Db,
|
||||||
error::MyError,
|
error::MyError,
|
||||||
requests::Requests,
|
requests::Requests,
|
||||||
response,
|
|
||||||
state::{State, UrlKind},
|
state::{State, UrlKind},
|
||||||
};
|
};
|
||||||
use activitystreams::{
|
use activitystreams::{
|
||||||
|
@ -102,7 +102,7 @@ async fn handle_undo(
|
||||||
let _ = client2.deliver(inbox, &undo2).await;
|
let _ = client2.deliver(inbox, &undo2).await;
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(response(undo))
|
Ok(accepted(undo))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_forward(
|
async fn handle_forward(
|
||||||
|
@ -116,7 +116,7 @@ async fn handle_forward(
|
||||||
let inboxes = get_inboxes(state, &actor, &object_id).await?;
|
let inboxes = get_inboxes(state, &actor, &object_id).await?;
|
||||||
client.deliver_many(inboxes, input.clone());
|
client.deliver_many(inboxes, input.clone());
|
||||||
|
|
||||||
Ok(response(input))
|
Ok(accepted(input))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_relay(
|
async fn handle_relay(
|
||||||
|
@ -139,7 +139,7 @@ async fn handle_relay(
|
||||||
|
|
||||||
state.cache(object_id.to_owned(), activity_id).await;
|
state.cache(object_id.to_owned(), activity_id).await;
|
||||||
|
|
||||||
Ok(response(announce))
|
Ok(accepted(announce))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_follow(
|
async fn handle_follow(
|
||||||
|
@ -180,7 +180,7 @@ async fn handle_follow(
|
||||||
let _ = client2.deliver(inbox, &accept2).await;
|
let _ = client2.deliver(inbox, &accept2).await;
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(response(accept))
|
Ok(accepted(accept))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate a type that says "I want to stop following you"
|
// Generate a type that says "I want to stop following you"
|
||||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -27,7 +27,7 @@ use self::{
|
||||||
webfinger::RelayResolver,
|
webfinger::RelayResolver,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn response<T>(item: T) -> HttpResponse
|
pub fn ok<T>(item: T) -> HttpResponse
|
||||||
where
|
where
|
||||||
T: serde::ser::Serialize,
|
T: serde::ser::Serialize,
|
||||||
{
|
{
|
||||||
|
@ -36,6 +36,15 @@ where
|
||||||
.json(item)
|
.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 {
|
async fn index() -> impl Responder {
|
||||||
"hewwo, mr obama"
|
"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()?,
|
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]
|
#[actix_rt::main]
|
||||||
|
|
Loading…
Reference in a new issue