fix(ap): resolve parent ap_id for replies so inReplyTo is set on outbound Notes

This commit is contained in:
2026-05-15 09:59:50 +02:00
parent 009b2d43c9
commit 2a51241bb5

View File

@@ -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