From 17886732dd7d8a0e820cae2cf77afdf4095c3845 Mon Sep 17 00:00:00 2001 From: asonix Date: Thu, 21 May 2020 17:00:55 -0500 Subject: [PATCH] Fix inbox resolution, fix notsubscribed message --- src/data/actor.rs | 11 +++++++++-- src/routes/inbox.rs | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/data/actor.rs b/src/data/actor.rs index 35676d0..d71d00b 100644 --- a/src/data/actor.rs +++ b/src/data/actor.rs @@ -63,7 +63,7 @@ impl ActorCache { let input_host = id.as_url().host(); let accepted_actor_id = accepted_actor.id().ok_or(MyError::MissingId)?; let actor_host = accepted_actor_id.as_url().host(); - let inbox_host = accepted_actor.inbox().as_url().host(); + let inbox_host = get_inbox(&accepted_actor).as_url().host(); if input_host != actor_host { let input_host = input_host.map(|h| h.to_string()).unwrap_or_default(); @@ -79,7 +79,7 @@ impl ActorCache { return Err(MyError::HostMismatch(actor_host, inbox_host)); } - let inbox = accepted_actor.inbox().clone(); + let inbox = get_inbox(&accepted_actor).clone(); let actor = Actor { id: accepted_actor_id.clone(), @@ -335,6 +335,13 @@ impl ActorCache { } } +fn get_inbox(actor: &AcceptedActors) -> &XsdAnyUri { + actor + .endpoints() + .and_then(|e| e.shared_inbox.as_ref()) + .unwrap_or(actor.inbox()) +} + #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] pub struct Actor { pub id: XsdAnyUri, diff --git a/src/routes/inbox.rs b/src/routes/inbox.rs index 6e73370..86ae42d 100644 --- a/src/routes/inbox.rs +++ b/src/routes/inbox.rs @@ -166,7 +166,7 @@ async fn handle_undo( jobs.queue(Forward::new(input, actor))?; return Ok(()); } else { - return Err(MyError::NotSubscribed(id_string(input.id())?)); + return Err(MyError::NotSubscribed(actor.inbox.to_string())); } }