feat: implement thought thread retrieval with replies and visibility filtering

This commit is contained in:
2025-09-07 14:47:30 +02:00
parent b337184a59
commit 40695b7ad3
14 changed files with 244 additions and 55 deletions

View File

@@ -8,18 +8,16 @@ use serde::Serialize;
use utoipa::ToSchema;
use uuid::Uuid;
#[derive(Serialize, ToSchema, FromQueryResult, Debug)]
#[derive(Serialize, ToSchema, FromQueryResult, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ThoughtSchema {
pub id: Uuid,
#[schema(example = "frutiger")]
#[serde(rename = "authorUsername")]
pub author_username: String,
#[schema(example = "This is my first thought! #welcome")]
pub content: String,
pub visibility: Visibility,
#[serde(rename = "replyToId")]
pub reply_to_id: Option<Uuid>,
#[serde(rename = "createdAt")]
pub created_at: DateTimeWithTimeZoneWrapper,
}
@@ -37,6 +35,7 @@ impl ThoughtSchema {
}
#[derive(Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct ThoughtListSchema {
pub thoughts: Vec<ThoughtSchema>,
}
@@ -70,3 +69,15 @@ impl From<ThoughtWithAuthor> for ThoughtSchema {
}
}
}
#[derive(Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct ThoughtThreadSchema {
pub id: Uuid,
pub author_username: String,
pub content: String,
pub visibility: Visibility,
pub reply_to_id: Option<Uuid>,
pub created_at: DateTimeWithTimeZoneWrapper,
pub replies: Vec<ThoughtThreadSchema>,
}

View File

@@ -6,21 +6,16 @@ use uuid::Uuid;
use crate::domains::user;
#[derive(Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct UserSchema {
pub id: Uuid,
pub username: String,
#[serde(rename = "displayName")]
pub display_name: Option<String>,
pub bio: Option<String>,
#[serde(rename = "avatarUrl")]
pub avatar_url: Option<String>,
#[serde(rename = "headerUrl")]
pub header_url: Option<String>,
#[serde(rename = "customCss")]
pub custom_css: Option<String>,
#[serde(rename = "topFriends")]
pub top_friends: Vec<String>,
#[serde(rename = "joinedAt")]
pub joined_at: DateTimeWithTimeZoneWrapper,
}
@@ -50,7 +45,7 @@ impl From<user::Model> for UserSchema {
avatar_url: user.avatar_url,
header_url: user.header_url,
custom_css: user.custom_css,
top_friends: vec![], // Defaults to an empty list
top_friends: vec![],
joined_at: user.created_at.into(),
}
}
@@ -70,8 +65,16 @@ impl From<Vec<user::Model>> for UserListSchema {
}
#[derive(Serialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct MeSchema {
#[serde(flatten)]
pub user: UserSchema,
pub id: Uuid,
pub username: String,
pub display_name: Option<String>,
pub bio: Option<String>,
pub avatar_url: Option<String>,
pub header_url: Option<String>,
pub custom_css: Option<String>,
pub top_friends: Vec<String>,
pub joined_at: DateTimeWithTimeZoneWrapper,
pub following: Vec<UserSchema>,
}