feat: v2 rewrite — hexagonal arch, ActivityPub federation, NATS, deployment-ready #1
@@ -116,9 +116,19 @@ impl ThoughtRepository for PgThoughtRepository {
|
||||
}
|
||||
|
||||
async fn get_thread(&self, id: &ThoughtId) -> Result<Vec<Thought>, DomainError> {
|
||||
sqlx::query_as::<_, ThoughtRow>(&format!(
|
||||
"{THOUGHT_SELECT} WHERE id=$1 OR in_reply_to_id=$1 ORDER BY created_at ASC"
|
||||
))
|
||||
// Recursive CTE: fetches the root thought and all nested replies at any depth.
|
||||
sqlx::query_as::<_, ThoughtRow>(
|
||||
"WITH RECURSIVE thread AS (
|
||||
SELECT id,user_id,content,in_reply_to_id,in_reply_to_url,ap_id,
|
||||
visibility,content_warning,sensitive,local,created_at,updated_at
|
||||
FROM thoughts WHERE id = $1
|
||||
UNION ALL
|
||||
SELECT t.id,t.user_id,t.content,t.in_reply_to_id,t.in_reply_to_url,t.ap_id,
|
||||
t.visibility,t.content_warning,t.sensitive,t.local,t.created_at,t.updated_at
|
||||
FROM thoughts t JOIN thread ON t.in_reply_to_id = thread.id
|
||||
)
|
||||
SELECT * FROM thread ORDER BY created_at ASC",
|
||||
)
|
||||
.bind(id.as_uuid())
|
||||
.fetch_all(&self.pool)
|
||||
.await
|
||||
|
||||
Reference in New Issue
Block a user