mirror of
https://git.asonix.dog/asonix/relay.git
synced 2024-11-28 20:41:33 +00:00
Properly forward Announce and Create
This commit is contained in:
parent
26b4129261
commit
e8ed464e62
1 changed files with 16 additions and 11 deletions
23
src/inbox.rs
23
src/inbox.rs
|
@ -61,9 +61,9 @@ pub async fn inbox(
|
||||||
|
|
||||||
match input.kind {
|
match input.kind {
|
||||||
ValidTypes::Announce | ValidTypes::Create => {
|
ValidTypes::Announce | ValidTypes::Create => {
|
||||||
handle_relay(&state, &client, input, actor).await
|
handle_announce(&state, &client, input, actor).await
|
||||||
}
|
}
|
||||||
ValidTypes::Follow => handle_follow(&db, &state, &client, input, actor).await,
|
ValidTypes::Follow => handle_follow(&db, &state, &client, input, actor, is_listener).await,
|
||||||
ValidTypes::Delete | ValidTypes::Update => {
|
ValidTypes::Delete | ValidTypes::Update => {
|
||||||
handle_forward(&state, &client, input, actor).await
|
handle_forward(&state, &client, input, actor).await
|
||||||
}
|
}
|
||||||
|
@ -78,11 +78,18 @@ async fn handle_undo(
|
||||||
input: AcceptedObjects,
|
input: AcceptedObjects,
|
||||||
actor: AcceptedActors,
|
actor: AcceptedActors,
|
||||||
) -> Result<HttpResponse, MyError> {
|
) -> Result<HttpResponse, MyError> {
|
||||||
if !input.object.is_kind("Follow") {
|
match input.object.kind() {
|
||||||
|
Some("Follow") | Some("Announce") | Some("Create") => (),
|
||||||
|
_ => {
|
||||||
return Err(MyError::Kind(
|
return Err(MyError::Kind(
|
||||||
input.object.kind().unwrap_or("unknown").to_owned(),
|
input.object.kind().unwrap_or("unknown").to_owned(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !input.object.is_kind("Follow") {
|
||||||
|
return handle_forward(state, client, input, actor).await;
|
||||||
|
}
|
||||||
|
|
||||||
let my_id: XsdAnyUri = state.generate_url(UrlKind::Actor).parse()?;
|
let my_id: XsdAnyUri = state.generate_url(UrlKind::Actor).parse()?;
|
||||||
|
|
||||||
|
@ -119,7 +126,7 @@ async fn handle_forward(
|
||||||
Ok(accepted(input))
|
Ok(accepted(input))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_relay(
|
async fn handle_announce(
|
||||||
state: &State,
|
state: &State,
|
||||||
client: &Requests,
|
client: &Requests,
|
||||||
input: AcceptedObjects,
|
input: AcceptedObjects,
|
||||||
|
@ -148,17 +155,15 @@ async fn handle_follow(
|
||||||
client: &Requests,
|
client: &Requests,
|
||||||
input: AcceptedObjects,
|
input: AcceptedObjects,
|
||||||
actor: AcceptedActors,
|
actor: AcceptedActors,
|
||||||
|
is_listener: bool,
|
||||||
) -> Result<HttpResponse, MyError> {
|
) -> Result<HttpResponse, MyError> {
|
||||||
let my_id: XsdAnyUri = state.generate_url(UrlKind::Actor).parse()?;
|
let my_id: XsdAnyUri = state.generate_url(UrlKind::Actor).parse()?;
|
||||||
|
|
||||||
if !input.object.is(&my_id) {
|
if !input.object.is(&my_id) && !input.object.is(&public()) {
|
||||||
error!("Wrong Actor, {:?}", input);
|
|
||||||
return Err(MyError::WrongActor(input.object.id().to_string()));
|
return Err(MyError::WrongActor(input.object.id().to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
let is_listener = state.is_listener(&actor.id).await;
|
if !is_listener && input.object.is(&my_id) {
|
||||||
|
|
||||||
if !is_listener {
|
|
||||||
let follow = generate_follow(state, &actor.id, &my_id)?;
|
let follow = generate_follow(state, &actor.id, &my_id)?;
|
||||||
|
|
||||||
let inbox = actor.inbox().to_owned();
|
let inbox = actor.inbox().to_owned();
|
||||||
|
|
Loading…
Reference in a new issue