From 7b1e26fa9e4dc54afc19e69c7e4f50c3d26b0088 Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Fri, 15 May 2026 11:51:57 +0200 Subject: [PATCH] =?UTF-8?q?fix(ap):=20propagate=20sharedInbox=20through=20?= =?UTF-8?q?DbActor=20=E2=80=94=20was=20hardcoded=20None=20everywhere?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/adapters/activitypub-base/src/actors.rs | 13 ++++++++++++- crates/adapters/activitypub-base/src/service.rs | 7 +++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/crates/adapters/activitypub-base/src/actors.rs b/crates/adapters/activitypub-base/src/actors.rs index f50364b..5bec4e3 100644 --- a/crates/adapters/activitypub-base/src/actors.rs +++ b/crates/adapters/activitypub-base/src/actors.rs @@ -22,6 +22,7 @@ pub struct DbActor { pub public_key_pem: String, pub private_key_pem: Option, pub inbox_url: Url, + pub shared_inbox_url: Option, pub outbox_url: Url, pub followers_url: Url, pub following_url: Url, @@ -118,6 +119,7 @@ pub async fn get_local_actor( let ap_id = crate::urls::actor_url(&data.base_url, user_id); let inbox_url = Url::parse(&format!("{}/inbox", &ap_id)).expect("valid inbox url"); + let shared_inbox_url = Url::parse(&format!("{}/inbox", data.base_url)).ok(); let outbox_url = Url::parse(&format!("{}/outbox", &ap_id)).expect("valid outbox url"); let followers_url = Url::parse(&format!("{}/followers", &ap_id)).expect("valid followers url"); let following_url = Url::parse(&format!("{}/following", &ap_id)).expect("valid following url"); @@ -128,6 +130,7 @@ pub async fn get_local_actor( public_key_pem: public_key, private_key_pem: Some(private_key), inbox_url, + shared_inbox_url, outbox_url, followers_url, following_url, @@ -181,6 +184,7 @@ impl Object for DbActor { let ap_id = crate::urls::actor_url(&data.base_url, user_id); let inbox_url = Url::parse(&format!("{}/inbox", &ap_id)).expect("valid url"); + let shared_inbox_url = Url::parse(&format!("{}/inbox", data.base_url)).ok(); let outbox_url = Url::parse(&format!("{}/outbox", &ap_id)).expect("valid url"); let followers_url = Url::parse(&format!("{}/followers", &ap_id)).expect("valid url"); let following_url = Url::parse(&format!("{}/following", &ap_id)).expect("valid url"); @@ -191,6 +195,7 @@ impl Object for DbActor { public_key_pem: public_key, private_key_pem: private_key, inbox_url, + shared_inbox_url, outbox_url, followers_url, following_url, @@ -268,11 +273,12 @@ impl Object for DbActor { } async fn from_json(json: Self::Kind, data: &Data) -> Result { + let shared_inbox_url = json.endpoints.as_ref().map(|e| e.shared_inbox.to_string()); let actor = RemoteActor { url: json.id.inner().to_string(), handle: json.preferred_username.clone(), inbox_url: json.inbox.to_string(), - shared_inbox_url: None, + shared_inbox_url, display_name: json.name.clone(), avatar_url: json.icon.as_ref().map(|i| i.url.to_string()), outbox_url: Some(json.outbox.to_string()), @@ -283,6 +289,10 @@ impl Object for DbActor { let user_id = uuid::Uuid::new_v5(&uuid::Uuid::NAMESPACE_URL, url_str.as_bytes()); let ap_id = json.id.inner().clone(); let inbox_url = json.inbox.clone(); + let shared_inbox_url = json + .endpoints + .as_ref() + .and_then(|e| Url::parse(e.shared_inbox.as_str()).ok()); let outbox_url = json.outbox.clone(); let followers_url = json.followers.clone(); let following_url = json.following.clone(); @@ -293,6 +303,7 @@ impl Object for DbActor { public_key_pem: json.public_key.public_key_pem, private_key_pem: None, inbox_url, + shared_inbox_url, outbox_url, followers_url, following_url, diff --git a/crates/adapters/activitypub-base/src/service.rs b/crates/adapters/activitypub-base/src/service.rs index 3e1fe6f..6b21679 100644 --- a/crates/adapters/activitypub-base/src/service.rs +++ b/crates/adapters/activitypub-base/src/service.rs @@ -575,7 +575,10 @@ impl ActivityPubService { url: remote_actor.ap_id.to_string(), handle: full_handle, inbox_url: remote_actor.inbox_url.to_string(), - shared_inbox_url: None, + shared_inbox_url: remote_actor + .shared_inbox_url + .as_ref() + .map(|u| u.to_string()), display_name: Some(remote_actor.username.clone()), avatar_url: remote_actor.avatar_url.as_ref().map(|u| u.to_string()), outbox_url: Some(remote_actor.outbox_url.to_string()), @@ -1638,7 +1641,7 @@ impl domain::ports::FederationActionPort for ActivityPubService { handle: full_handle, display_name: Some(actor.username.clone()), inbox_url: actor.inbox_url.to_string(), - shared_inbox_url: None, + shared_inbox_url: actor.shared_inbox_url.as_ref().map(|u| u.to_string()), public_key: actor.public_key_pem.clone(), avatar_url: actor.avatar_url.as_ref().map(|u| u.to_string()), last_fetched_at: actor.last_refreshed_at,