feat: add in_reply_to_url field to FeedRow and ThoughtRow, update related queries and handlers
This commit is contained in:
@@ -34,6 +34,7 @@ impl OutboxRow {
|
||||
user_id: UserId::from_uuid(self.user_id),
|
||||
content: Content::new_remote(self.content),
|
||||
in_reply_to_id: self.in_reply_to_id.map(ThoughtId::from_uuid),
|
||||
in_reply_to_url: None,
|
||||
visibility: Visibility::Public,
|
||||
content_warning: self.content_warning,
|
||||
sensitive: self.sensitive,
|
||||
|
||||
@@ -29,6 +29,7 @@ struct FeedRow {
|
||||
t_user_id: uuid::Uuid,
|
||||
content: String,
|
||||
in_reply_to_id: Option<uuid::Uuid>,
|
||||
in_reply_to_url: Option<String>,
|
||||
visibility: String,
|
||||
content_warning: Option<String>,
|
||||
sensitive: bool,
|
||||
@@ -52,6 +53,7 @@ fn row_to_entry(r: FeedRow, viewer: Option<uuid::Uuid>) -> Result<FeedEntry, Dom
|
||||
user_id: UserId::from_uuid(r.t_user_id),
|
||||
content: Content::new_remote(r.content),
|
||||
in_reply_to_id: r.in_reply_to_id.map(ThoughtId::from_uuid),
|
||||
in_reply_to_url: r.in_reply_to_url,
|
||||
visibility: Visibility::from_db_str(&r.visibility)?,
|
||||
content_warning: r.content_warning,
|
||||
sensitive: r.sensitive,
|
||||
@@ -111,7 +113,7 @@ impl<'a> FeedSqlBuilder<'a> {
|
||||
"
|
||||
SELECT
|
||||
t.id AS thought_id, t.user_id AS t_user_id, t.content,
|
||||
t.in_reply_to_id,
|
||||
t.in_reply_to_id, t.in_reply_to_url,
|
||||
t.visibility, t.content_warning, t.sensitive, t.local AS t_local,
|
||||
t.created_at AS thought_created_at, t.updated_at AS thought_updated_at,
|
||||
t.note_extensions, t.mood,
|
||||
|
||||
@@ -28,6 +28,7 @@ pub(crate) struct ThoughtRow {
|
||||
pub user_id: uuid::Uuid,
|
||||
pub content: String,
|
||||
pub in_reply_to_id: Option<uuid::Uuid>,
|
||||
pub in_reply_to_url: Option<String>,
|
||||
pub visibility: String,
|
||||
pub content_warning: Option<String>,
|
||||
pub sensitive: bool,
|
||||
@@ -46,6 +47,7 @@ impl TryFrom<ThoughtRow> for Thought {
|
||||
user_id: UserId::from_uuid(r.user_id),
|
||||
content: Content::new_remote(r.content),
|
||||
in_reply_to_id: r.in_reply_to_id.map(ThoughtId::from_uuid),
|
||||
in_reply_to_url: r.in_reply_to_url,
|
||||
visibility: Visibility::from_db_str(&r.visibility)?,
|
||||
content_warning: r.content_warning,
|
||||
sensitive: r.sensitive,
|
||||
@@ -59,7 +61,7 @@ impl TryFrom<ThoughtRow> for Thought {
|
||||
}
|
||||
|
||||
const THOUGHT_SELECT: &str =
|
||||
"SELECT id,user_id,content,in_reply_to_id,visibility,content_warning,sensitive,local,created_at,updated_at,note_extensions,mood FROM thoughts";
|
||||
"SELECT id,user_id,content,in_reply_to_id,in_reply_to_url,visibility,content_warning,sensitive,local,created_at,updated_at,note_extensions,mood FROM thoughts";
|
||||
|
||||
#[async_trait]
|
||||
impl ThoughtRepository for PgThoughtRepository {
|
||||
@@ -121,11 +123,11 @@ impl ThoughtRepository for PgThoughtRepository {
|
||||
// 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,
|
||||
SELECT id,user_id,content,in_reply_to_id,in_reply_to_url,
|
||||
visibility,content_warning,sensitive,local,created_at,updated_at,note_extensions,mood
|
||||
FROM thoughts WHERE id = $1
|
||||
UNION ALL
|
||||
SELECT t.id,t.user_id,t.content,t.in_reply_to_id,
|
||||
SELECT t.id,t.user_id,t.content,t.in_reply_to_id,t.in_reply_to_url,
|
||||
t.visibility,t.content_warning,t.sensitive,t.local,t.created_at,t.updated_at,t.note_extensions,t.mood
|
||||
FROM thoughts t JOIN thread ON t.in_reply_to_id = thread.id
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user