Anonymizing response data with sibling types that doesent contain any userId
This commit is contained in:
parent
dcf5f012f8
commit
96c720a3ad
6 changed files with 63 additions and 54 deletions
|
|
@ -10,7 +10,6 @@ pub struct NewComment {
|
|||
}
|
||||
|
||||
/// The comment as it is stored in the database, with all the related metadata
|
||||
/// This is also the comment as it is sent to the client
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, sqlx::FromRow)]
|
||||
pub struct Comment {
|
||||
pub id: i64,
|
||||
|
|
@ -24,6 +23,19 @@ pub struct Comment {
|
|||
pub updated_at: chrono::NaiveDateTime,
|
||||
}
|
||||
|
||||
/// This is the comment as it is sent to the client, with only the public metadata
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, sqlx::FromRow)]
|
||||
pub struct PublicComment {
|
||||
pub id: i64,
|
||||
pub parent_post_id: i64,
|
||||
pub parent_comment_id: Option<i64>,
|
||||
pub upvotes: i64,
|
||||
pub downvotes: i64,
|
||||
pub content: String,
|
||||
pub created_at: chrono::NaiveDateTime,
|
||||
pub updated_at: chrono::NaiveDateTime,
|
||||
}
|
||||
|
||||
/// Query parameters for the /comments endpoint
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct CommentQueryParams {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,17 @@ pub struct Post {
|
|||
pub updated_at: chrono::NaiveDateTime,
|
||||
}
|
||||
|
||||
// The post as it is sent to the client, with only the public metadata
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, FromRow)]
|
||||
pub struct PublicPost {
|
||||
pub id: i64,
|
||||
pub content: String,
|
||||
pub upvotes: i64,
|
||||
pub downvotes: i64,
|
||||
pub created_at: chrono::NaiveDateTime,
|
||||
pub updated_at: chrono::NaiveDateTime,
|
||||
}
|
||||
|
||||
// These look like /posts?limit=10&offset=20 in the URL
|
||||
// Note that these are optional
|
||||
/// Query parameters for the /posts endpoint
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue