From 2a51241bb58f1543671ad5707e5a410af9908f41 Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Fri, 15 May 2026 09:59:50 +0200 Subject: [PATCH] fix(ap): resolve parent ap_id for replies so inReplyTo is set on outbound Notes --- .../src/services/federation_event.rs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/crates/application/src/services/federation_event.rs b/crates/application/src/services/federation_event.rs index 5fe335a..5fa432f 100644 --- a/crates/application/src/services/federation_event.rs +++ b/crates/application/src/services/federation_event.rs @@ -48,6 +48,29 @@ impl FederationEventService { Some(u) => u, None => return Ok(()), }; + // For replies to remote posts: in_reply_to_url is None but in_reply_to_id + // points to the locally-stored remote thought. Resolve its ap_id so the + // outbound Note includes inReplyTo and Mastodon threads it correctly. + let thought = if thought.in_reply_to_url.is_none() { + if let Some(ref reply_id) = thought.in_reply_to_id { + match self.thoughts.find_by_id(reply_id).await? { + Some(parent) => { + let parent_ap_url = parent.ap_id.unwrap_or_else(|| { + format!("{}/thoughts/{}", self.base_url, reply_id) + }); + domain::models::thought::Thought { + in_reply_to_url: Some(parent_ap_url), + ..thought + } + } + None => thought, + } + } else { + thought + } + } else { + thought + }; self.ap .broadcast_create(user_id, &thought, user.username.as_str()) .await