From c2da86d82951553eb326f9e5a127e2681ec6bedd Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 13 Feb 2023 23:16:21 -0800 Subject: [PATCH] adds some docs and comments --- src/conf.rs | 2 +- src/services/posts.rs | 1 + src/types.rs | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/conf.rs b/src/conf.rs index 1681787..6dd627e 100644 --- a/src/conf.rs +++ b/src/conf.rs @@ -10,7 +10,7 @@ pub const SESSION_MIN_TIME_BETWEEN_REFRESH: Duration = Duration::from_secs(3600 pub const POSTS_PAGE_SIZE: u16 = 20; /// The maximum length of a post in UTF-8 bytes. -pub const POST_HEADER_MAX_SIZE: usize = 150; +pub const POST_HEADER_MAX_SIZE: usize = 120; /// The maximum length of a post in UTF-8 bytes. pub const POST_BODY_MAX_SIZE: usize = 1000; diff --git a/src/services/posts.rs b/src/services/posts.rs index cc74364..0d12ce2 100644 --- a/src/services/posts.rs +++ b/src/services/posts.rs @@ -48,6 +48,7 @@ pub enum ListQuery { Trending, } +/// Fields that are sent up with a post in order to help create it. #[derive(Deserialize)] pub struct CreateRequest { pub school_id: String, diff --git a/src/types.rs b/src/types.rs index 450fda9..17101ea 100644 --- a/src/types.rs +++ b/src/types.rs @@ -72,17 +72,22 @@ pub struct Post { #[serde(rename = "_id")] pub id: ObjectId, pub sequential_id: i32, + // If this post is replying (meaning it's a "child") to another post. pub reply_context: Option, pub owner: ObjectId, + // Unique school identifier. pub school_id: String, pub header_text: String, pub body_text: String, + // Genre of the post. pub genre: PostGenre, pub votes_up: i32, pub votes_down: i32, pub absolute_score: i32, pub trending_score: f64, pub created_at: DateTime, + // If the user wants this post associated with them privately (aka, do they want it + // linked to their private profile so they can find it easily), or completely disassociated. pub associated_with_user: bool, }